获取用户主要详细信息

时间:2018-07-23 04:14:11

标签: asp.net asp.net-mvc iis

当我的代码是:

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会引发错误:

  

对象引用未设置为对象的实例。

发生了什么事?

1 个答案:

答案 0 :(得分:0)

请通过在Web.config的system.web内部添加这个节点来重试。(删除身份之前的空格)

问题在于冒充。

请检查并还原。

谢谢