使用LdapConnection时提供的凭据无效

时间:2017-04-03 19:45:02

标签: c# ldap

我正在尝试连接到LDAP服务器并进行一些搜索。我正在使用LdapConnection和NetworkCredential对象来执行此操作。这是我的代码示例。当我尝试绑定时,我收到一个错误,指出

  

“提供的凭据无效。”

我认为我的问题是我没有正确传递Domain的预期值。这是我第一次使用这些对象编程,我一直在努力寻找一个适合我的例子。非常感谢您提供的任何帮助!

string myServerName = "111.22.333.444:389";

string myUserName = "MyLogin,ou=Systems,ou=LOCATION,o=Internal,dc=MYCOMPANY,dc=COM";

string myPassword = "MyPassword";

string myDomain = "ou=Systems,ou=LOCATION,o=Internal,dc=MYCOMPANY,dc=COM";

LdapConnection myConnection = new LdapConnection(myServerName);

NetworkCredetial myCredential = new NetworkCredential(myUserName, myPassword, myDomain);

myConnection.Bind(myCredential);

0 个答案:

没有答案