Reset ldap user password (Error : The server cannot handle directory requests. )

家住魔仙堡 提交于 2019-12-13 07:24:16

问题


I am using this code:

LdapConnection connection = new LdapConnection(new LdapDirectoryIdentifier("DOMAIN",636));

connection.SessionOptions.VerifyServerCertificate =
            new VerifyServerCertificateCallback((con, cer) => true);
connection.SessionOptions.ProtocolVersion = 3;
connection.AuthType = AuthType.Basic;
connection.Credential = new NetworkCredential("CN=user,CN=Users,DC=DOMAIN","password!");

connection.SessionOptions.SecureSocketLayer=true;

using(connection)
{
  connection.Bind();

  SearchRequest request = new SearchRequest("CN=Users,DC=DOMAIN", "CN=mayank",    System.DirectoryServices.Protocols.SearchScope.Subtree);

  SearchResponse response = (SearchResponse)connection.SendRequest(request);

  SearchResultEntry entry = response.Entries[0];

  DirectoryAttributeModification modifyUserPassword = new DirectoryAttributeModification();
        modifyUserPassword.Operation = DirectoryAttributeOperation.Replace;
        modifyUserPassword.Name = "unicodePwd";
        modifyUserPassword.Add(GetPasswordData("admin1234!"));

        ModifyRequest modifyRequest = new ModifyRequest(entry.DistinguishedName, modifyUserPassword);
        DirectoryResponse dirResponse = connection.SendRequest(modifyRequest);

}

This successfully connects to LDAP but when one attempts to change the password, it throws an error stating "The server cannot handle directory requests."

来源:https://stackoverflow.com/questions/12635484/reset-ldap-user-password-error-the-server-cannot-handle-directory-requests

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!