首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用System.DirectoryServices.Protocols更改密码

如何使用System.DirectoryServices.Protocols更改密码
EN

Stack Overflow用户
提问于 2009-10-09 14:57:05
回答 4查看 9.8K关注 0票数 1

我们的用户存储是一个名为eDirectory的LDAP服务器。如何使用System.DirectoryServices.Protocols更改用户密码?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2009-10-12 07:52:25

我使用类似于此的代码连接到基于Sun One的LDAP来更改用户密码。(不应该与Novell eDirectory有太大不同...)

代码语言:javascript
复制
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);
票数 5
EN

Stack Overflow用户

发布于 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示例

代码语言:javascript
复制
dn: cn=<myuser>,ou=<myou>,o=<myo>
changetype: modify
replace: userPassword
userPassword: <newPassWord>
票数 1
EN

Stack Overflow用户

发布于 2011-08-25 09:02:17

我同意Per Noalt和Matthew Whited的两种方法。但这里有一个微妙的重要之处。

用户密码更改和管理密码更改之间存在差异。

如果您更换userPassword,这是管理员密码更改,根据密码策略,密码可能会立即过期。(eDir使用密码过期,然后使用宽限登录计数)。

如果您提供旧密码和新密码,则您正在执行用户启动的密码重置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1544336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档