当我的代码是:
UserPrincipal up = UserPrincipal.FindByIdentity(Context, IdentityType.SamAccountName, "Username");
在Visual Studio和IIS中可以。
但是,当我将代码更改为:
string Name = WindowsIdentity.GetCurrent().Name;
UserPrincipal up = UserPrincipal.FindByIdentity(Context, IdentityType.SamAccountName, Name);
在Visual Studio中可以,但是IIS会引发错误:
对象引用未设置为对象的实例。
发生了什么事?
答案 0 :(得分:0)
请通过在Web.config的system.web内部添加
问题在于冒充。
请检查并还原。
谢谢