0

sharepoint 2003 があります。Web パーツを開発しました。

ユーザーが Web パーツにアクセスすると、サーバー側で認証が行われます。

Web アプリに要求を送信するには、Web パーツ内で必要です。Web アプリがデプロイされているサーバーにリクエストを送信すると、Web パーツがデプロイされたサーバー アカウントにログインしようとします。

そして、Web パーツにアクセスするユーザー アカウントを認証するために使用される Web アプリが展開されているサーバーに要求を送信するときに必要です。

認証タイプ: NTLM

Web パーツにアクセスしたユーザー名の Web アプリに、Web パーツはどのようにアクセスできますか?


2 つの解決策が見つかりました。

1.次の内容で WebPart に Web.config を追加します。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <authentication mode="Windows" />
    <identity impersonate="true" />
  </system.web>
</configuration>

それは役に立ちません。理由は明らかではありません。

2.次のコードを使用します。

        WindowsIdentity winId = (WindowsIdentity)Context.User.Identity;
        WindowsImpersonationContext ctx = null;

        try
        {
            // Start impersonating.
            ctx = winId.Impersonate();
            // Now impersonating.
            // Access resources using the identity of the authenticated user.
            _autocompleteService.SendParametersForAutoComplete(_loger,
                        new KeyValuePairString("performerId", performerId),
                        new KeyValuePairString("templatePath",
                                                StringConverter.EncodeToURL(templatePath)),
                        new KeyValuePairString("specificationId", specificationId),
                        new KeyValuePairString("buyerId", buyerId),
                        new KeyValuePairString("performerCompanyId", performerCompanyId),
                        new KeyValuePairString("reestrItemId", reestrItemId),
                        new KeyValuePairString("sessionId", sessionId));
        }
        // Prevent exceptions from propagating.
        catch
        {
        }
        finally
        {
            if (ctx != null) ctx.Undo();
        }

このコードは次のリンクから取得できます: http://msdn.microsoft.com/en-us/library/aa480475.aspx

それは役に立ちません。理由は明らかではありません。

両方の場合の理由は何ですか?

4

1 に答える 1