【发布时间】:2013-06-25 19:43:23
【问题描述】:
我正在尝试在 LDAP 上运行查询,但出现 UnauthorizedAccessException @ new PrincipalSearcher(qbeUser) 异常。 (见下面的代码)
我不明白为什么应用程序在我运行时无权运行此查询 ldapsearch 命令行工具运行良好。
using(PrincipalContext ctx = new PrincipalContext(ContextType.Machine, "machineName"))
{
using(UserPrincipal qbeUser = new UserPrincipal(ctx))
{
using (PrincipalSearcher srch = new PrincipalSearcher(qbeUser))
{
foreach (var found in srch.FindAll())
{
var user = (UserPrincipal)found;
Console.WriteLine(user.GivenName + " " + user.Surname + " " + user.EmailAddress);
}
}
}
}
【问题讨论】:
-
当你从命令行使用
ldapsearch时,你是在以管理员身份运行命令行实例吗? -
是的,但是我的帐户是管理员组的一部分,所以我希望可以工作。无论哪种方式,我在管理员下运行 Visual Studio,也尝试像 Debug>Debug As Administrator 一样运行...仍然无法正常工作。
标签: c# .net ldap lotus-domino