我已经安装了一个openldap for windows
服务器,我用LDAPAdmin
它的默认值连接到它:
Server=ldap://localhost:389
Base:dc=maxcrc,dc=com
UserName:cn=Manager,dc=maxcrc,dc=com
Password:secret
现在我想使用PrincipalContext
将用户添加到我ou=People
的问题是我什至无法使用 PrincipalContext 连接到服务器。我在网上搜索了很多关于如何连接到 ldap 服务器的答案,但没有一个对我有用。我不断获得PrincipalContext 构造函数提供的参数NullReferenceException
的ServerNotFoundException
不同组合。我想我可以使用 PrincipalContext 作为以下之一:
new PirncipalContext(ContextType.Domain,"maxcrc.com","dc=maxcrc,dc=com")
或者
new PrincipalContext(ContextType.ApplicationDirectory,"localhost:389","dc=maxcrc,dc=com")
但他们都没有工作。有人说我应该提供用户名和密码,所以我这样做了,但我不断收到异常。
那么请告诉我如何使用 PrincipalContext 连接到 openldap ?
PS 我的电脑已经加入了一个 Active Directory 域控制器。