【发布时间】:2015-05-12 14:48:54
【问题描述】:
我正在使用 API System.DirectoryServices.AccountManagement 绑定到 AD-LDS 实例。我正在对 AD-LDS 实例中本地存在的用户使用简单绑定。当我在托管 AD-LDS 的服务器上运行客户端时它可以工作,但当我在远程计算机上运行客户端时它不起作用。
这是我用来绑定和搜索用户的代码:
var c = new PrincipalContext(ContextType.ApplicationDirectory, "fullhostname:50001", "CN=Users,DC=app,DC=local", ContextOptions.SimpleBind, "CN=joe,CN=Users,DC=app,DC=local", "abc");
var u = UserPrincipal.FindByIdentity(c, IdentityType.Name, "john");
这是我在远程计算机上运行时抛出的异常:
System.DirectoryServices.AccountManagement.PrincipalServerDownException: The server is not operational.
---> System.Runtime.InteropServices.COMException: The server is not operational.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectoryEntry.get_Options()
at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()
--- End of inner exception stack trace ---
at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInit()
at System.DirectoryServices.AccountManagement.PrincipalContext.DoApplicationDirectoryInit()
at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
at System.DirectoryServices.AccountManagement.PrincipalContext.get_ConnectedServer()
at MyApplication.DiagnosticsController.TryAdLdsSettings(AdLdsData data) in C:\code\MyApplication\DiagnosticsController.cs:line 166
如果我改用 System.DirectoryServices API,它也可以在远程计算机上工作:
var obj = new DirectoryEntry("LDAP://fullhostname:50001/CN=Users,DC=app,DC=local", "CN=joe,CN=Users,DC=app,DC=local",
"abc", AuthenticationTypes.None);
obj.RefreshCache();
这可行,但我需要改用 System.DirectoryServices.AccountManagement API。
有谁知道怎么回事?
【问题讨论】:
-
kls,有什么进展或解决方案吗?我觉得我在这里遇到了同样的问题。
-
@petty - 您可以编辑完整例外的问题,还是发布包含更多详细信息的非答案答案? PrincipleServerDownException 中应该有一个 LdapException,其中包含有关失败性质的更多信息。
-
@antiduh 我用更多信息编辑了这个问题(目前正在同行评审中)。不幸的是,我没有看到 LdapException - 只是一个 COMException。
标签: c# .net directoryservices account-management adlds