3

私のASP.NETWebアプリケーションは、イントラネットでWindows認証を使用しています。同じドメイン上の別のサーバーに対してサーバー側のhttpリクエストを実行できるようにしたいのですが、これにもWindows認証が必要です。

ここで追加のリクエストを行うときに、認証されたユーザーを一時的に偽装する手順に従いました。

http://msdn.microsoft.com/en-us/library/ff647404.aspx

次のようなコードを使用します。

using System.Security.Principal;

// Obtain the authenticated user's Identity
WindowsIdentity winId = (WindowsIdentity)HttpContext.Current.User.Identity;
WindowsImpersonationContext ctx = null;
try
{
  // Start impersonating
  ctx = winId.Impersonate();
  // Now impersonating
  // Access resources using the identity of the authenticated user
  var request = WebRequest.Create("http://intranet/secureapp");
  request.Credentials = CredentialCache.DefaultCredentials;
  var response = request.GetResponse();
  using (var streamReader = new StreamReader(response.GetResponseStream()))
  {
      Response.Write(streamReader.ReadToEnd());
  }
}
// Prevent exceptions from propagating
catch
{
}
finally
{
  // Revert impersonation
  if (ctx != null)
    ctx.Undo();
}
// Back to running under the default ASP.NET process identity 

しかし、残念ながら、私は常に401の不正なエラーを受け取ります。

Webサーバーをアクティブディレクトリで構成して、認証されたユーザーを委任できるようにする必要がありますか(約200人のユーザーのいずれかである可能性があるため、200回何もする必要はありません:))?もしそうなら、誰かがこれを行う方法を教えてもらえますか?

4

2 に答える 2

3

WindowsでKerberos/委任を構成するにはいくつかの手順があります。

まず、委任を使用するようにASP.NETを構成する必要があります。これはweb.configで構成されていると思います。

次に、委任用にASP.NETサービスアカウントを構成する必要があります。SPNを作成する必要がある場合があります。

次に、IISサーバーとActiveDirectoryのアカウントの委任を有効にします。

手順の説明は次のとおりです。http: //msdn.microsoft.com/en-us/library/ms998355.aspx 手順1〜3に従います。

于 2010-12-02T15:07:25.037 に答える