【发布时间】:2017-04-04 03:27:06
【问题描述】:
我对这个完全陌生
我尝试使用以下代码连接到 ldap 服务器。
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, "abcdef", "OU=abcdef,DC=avengers,DC=net");
我收到“LDAP 服务器不可用”异常。
我查看了其他建议添加用户名和密码的帖子,但我想使用这个特定的重载方法,它只接受 Context.Domain、Domain 和 Container 参数。
任何建议将不胜感激。
【问题讨论】:
-
当我做类似的事情时,我也遇到了使用
PrincipalContext对象的问题。通过使用变量,我能够访问 AD 属性。例如:var context = new PrincipalContext(ContextType.Domain, "pc-name", "DC=domain,DC=com", "user", "password"); ; UserPrincipal user = UserPrincipal.FindByIdentity(context, User.Identity.Name);