使用PrincipalContext的LDAP连接 [英] LDAP connection using PrincipalContext
本文介绍了使用PrincipalContext的LDAP连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须连接到apache服务器上的本地ldap。我用这样的代码
Hi,
I have to connect to local ldap which is on apache server. I use your code like this
private string sDomain = "ldap://localhost:10389";
private string sDefaultOU = "ou=users,ou=system";
private string sServiceUser = @"uid=admin,ou=system";
private string sServicePassword = "secret";
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, sDomain, sDefaultOU, sServiceUser, sServicePassword);
但是我没有连接,我正在做的任何事情都错了。
But I didn't get connected, anything wrong I am doing.
推荐答案
给它的时间有点迟了你是我的解决方案 - 但如果遇到同样的问题,对其他人会有用。
可能的解决方案如下
Its bit late to give you my solution - but It would be useful for others if the encounter the same issue.
Possible solution would be as follows
private string sDomain = "localhost:10389";
//sDomain is ServerName or Hosename or just IP address
//You had it with ldap://
private string sDefaultOU = "ou=users,ou=system";
private string sServiceUser = @"uid=admin,ou=system";
private string sServicePassword = "secret";
PrincipalContext oPrincipalContext = new PrincipalContext
(ContextType.Domain, sDomain, sDefaultOU, sServiceUser, sServicePassword);
希望这有帮助,它对我有用。
Hope this helps and it worked for me.
你不是传递正确的参数。
五参数构造函数重载第三个参数不是默认OU ,它是默认容器!因此,您需要使用DC-s对其进行限定。并且用户名参数不需要使用OU限定,只使用admin字符串。
请点击此处:使用System.DirectoryServices.AccountManagement [ ^ ]
You are not passing the right parameters.
The five parameter constructor overload's third parameter is not default OU, it is default container! Thus you need to qualify it with DC-s. And the user name parameter need not be qualified with OU, use just the "admin" string.
Check also here: Using System.DirectoryServices.AccountManagement[^]
这篇关于使用PrincipalContext的LDAP连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文