重置ldap用户密码(错误:服务器无法处理目录请求。)

时间:2012-09-28 07:26:10

标签: c#-4.0 openldap

我正在使用此代码:

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);

}

这成功连接到LDAP但是当一个人尝试更改密码时,会抛出错误,指出“服务器无法处理目录请求。”

0 个答案:

没有答案