PrincipalContext-我无法连接到本地openldap服务器 [英] PrincipalContext - I Can't connect to a local openldap server
问题描述
我已经安装了openldap for windows
服务器,并使用LDAPAdmin
通过其默认值连接到服务器:
I have installed an openldap for windows
server and I use LDAPAdmin
to connect to it by its default values :
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用作以下内容之一:
Now I want to use PrincipalContext
to add users to my ou=People
The problem is I can't even connect to the server using PrincipalContext. I have searched the Net and found a lot of answers on how to connect to a ldap server but none of them are working for me.I keep getting a NullReferenceException
or ServerNotFoundException
for different combination of provided parameters for PrincipalContext constructor.
I thought I could use PrincipalContext as one of the follows :
new PirncipalContext(ContextType.Domain,"maxcrc.com","dc=maxcrc,dc=com")
或
new PrincipalContext(ContextType.ApplicationDirectory,"localhost:389","dc=maxcrc,dc=com")
但是它们都不起作用.有人说我应该提供用户名和密码,所以我这样做了,但是我一直在例外.
but none of them are working.Some say that I should provide username and password so I did that but I keep getting exception.
所以请告诉我如何使用PrincipalContext连接到openldap?
So please tell me how can I use PrincipalContext to connect to openldap ?
P.S.我的计算机已经加入了Active Directory域控制器.
P.S. My computer is already joined to an Active Directory domain controller.