我们的用户存储是一个名为eDirectory的LDAP服务器。如何使用System.DirectoryServices.Protocols更改用户密码?
发布于 2009-10-12 07:52:25
我使用类似于此的代码连接到基于Sun One的LDAP来更改用户密码。(不应该与Novell eDirectory有太大不同...)
using System.DirectoryServices.Protocols;
using System.Net;
//...
// Connect to the directory:
LdapDirectoryIdentifier ldi = new LdapDirectoryIdentifier("theServerOrDirectoryName");
// You might need to specify a full DN for "theUsername" (I had to):
NetworkCredential nc = new NetworkCredential("theUsername", "theOldPassword");
// You might need to experiment with setting a different AuthType:
LdapConnection connection = new LdapConnection(ldi, nc, AuthType.Negotiate);
DirectoryAttributeModification modifyUserPassword = new DirectoryAttributeModification();
modifyUserPassword.Operation = DirectoryAttributeOperation.Replace;
modifyUserPassword.Name = "userPassword";
modifyUserPassword.Add("theNewPassword");
ModifyRequest modifyRequest = new ModifyRequest("theUsername", modifyUserPassword);
DirectoryResponse response = connection.SendRequest(modifyRequest);发布于 2009-10-09 15:52:13
您需要删除密码,然后重新添加。当我这样做时,我使用了Novell的LDAP库。您可能需要尝试使用DirectoryEntry才能使其正常工作。
Deleting non readable attribute from eDirectory - LDAP through ADSI/System.DirectoryServices
根据您在eDirectory中使用的密码类型,您可能会遇到问题
LDAP / Universal Password with eDirectory 8.8
How to change eDirectory or Universal Password through LDAP这里是一个ldif示例
dn: cn=<myuser>,ou=<myou>,o=<myo>
changetype: modify
replace: userPassword
userPassword: <newPassWord>发布于 2011-08-25 09:02:17
我同意Per Noalt和Matthew Whited的两种方法。但这里有一个微妙的重要之处。
用户密码更改和管理密码更改之间存在差异。
如果您更换userPassword,这是管理员密码更改,根据密码策略,密码可能会立即过期。(eDir使用密码过期,然后使用宽限登录计数)。
如果您提供旧密码和新密码,则您正在执行用户启动的密码重置。
https://stackoverflow.com/questions/1544336
复制相似问题