【问题标题】:Get userprincipal details获取用户主体详细信息
【发布时间】:2018-07-23 04:14:10
【问题描述】:

当我的代码是:

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 抛出错误:

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

发生了什么?

【问题讨论】:

  • 看起来您正在访问属性或调用NULL 对象的方法。
  • NO Shyju!在 Visual Studio 中调试时,方法获取值但在 IIS 上返回 null!

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


【解决方案1】:

请在web.config的system.web中添加这个节点重试。(去掉identity前的空格)

问题在于冒充。

请检查并恢复。

谢谢

【讨论】:

  • 我在 system.web 中使用 ,但是问题没有解决!!
猜你喜欢
  • 2014-11-08
  • 2014-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多