System.DirectoryServices.AccountManagement.UserPrincipal-localhostですが、iisではありません



System Directoryservices



解決:

UserPrincipal.Currentのデプロイで多くの問題が発生しましたが、その理由をまだ完全には理解していません。

最終的にPrincipalSearcherを使用し、UserPrincipal.Currentが実行していると思っていたことを実行するために次の関数を作成しました。



private UserPrincipal GetActiveDirectoryUser(string userName){using(var ctx = new PrincipalContext(ContextType.Domain))using(var user = new UserPrincipal(ctx){SamAccountName = userName})using(var searcher = new PrincipalSearcher(user)){return userPrincipalとしてのsearcher.FindOne(); }}

そして、System.Web.HttpContext.Current.User.Identity.NameをuserNameとしてそのメソッドに渡しました。


ユーザーを特定するには、他の方法が必要なようです。
プロパティのmsdnからの説明は次のとおりです。
'スレッドが実行されている現在のユーザーを表すユーザープリンシパルオブジェクトを取得します。'
したがって、UserPrincipal.Currentは、IISが実行している下のユーザーを返します。

http://msdn.microsoft.com/en-us/library/system.directoryservices.accountmanagement.userprincipal.aspx