【发布时间】:2012-06-15 18:37:49
【问题描述】:
我正在尝试跟踪应用程序错误,但我不是 WinNT 提供程序方面的专家。这是我正在调试的代码:
public string GetCurrentRequesterIdentity()
{
var a = HttpContext.Current.User.Identity.Name.Split('\\');
using (var adEntry = new DirectoryEntry("WinNT://" + a[0] + "/" + a[1]))
{
return adEntry.Properties["FullName"].Value.ToString();
}
}
当我调试此代码并运行 "?New DirectoryEntry("WinNT://DOMAIN/User")" 其中 DOMAIN 和 User 是(假定)有效条目时,窗口会为 ObjectSecurity 行返回以下内容:
ObjectSecurity: 'new DirectoryEntry("WinNT://[DOMAIN]/[USER]").ObjectSecurity' 引发了类型为 'System.NullReferenceException' 的异常
我看到应用程序抛出“找不到网络路径”错误。我只能复制一次这个错误,不能再复制一次。不幸的是,对于 2 个生产用户,几乎每次都会发生这种情况,但在测试环境中从未发生过。
以前有人见过这种情况吗?或者知道在哪里可以找到它?
【问题讨论】:
标签: c# active-directory