1

looking for some info on where to change this... I have a .net 4 web app sitting on one box and its SQL db sitting on another. The users windows AD login is picked up and used throughout the app with

System.Security.Principal.WindowsIdentity.GetCurrent().Name;

If I run the app locally, I get the correct login eg "MyDomain\MyLogin", If I hit the app on its host box the login picked up becomes "IIS APPPOOL\ASB", ASB being the name of the AppPool used (and the name of the app). I really need to return "MyDomain\MyLogin", so should I use a different approach?

thanks

4

1 に答える 1

0

Web アプリケーションで接続ユーザーのセキュリティ コンテキストを実行する場合は<system.web>、web.config ファイルのセクションに次を追加する必要があります。

  <authentication mode="Windows" />
  <identity impersonate="true" />

1 行目はIIS にユーザーの認証方法を伝え、2 行目はIIS アプリケーション プールのセキュリティ コンテキストではなく、接続されたユーザーのセキュリティ コンテキストで Web アプリケーションを実行することを ASP.Net に伝えます。

identity 要素を使用して、すべてのリクエストが特定のユーザーのコンテキストで実行されるように指定することもできます。

于 2012-08-02T15:46:33.350 に答える