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

发布于 2024-08-06 18:13:39 字数 89 浏览 11 评论 0原文

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

Our user store is an LDAP server called eDirectory. How do you change user passwords using System.DirectoryServices.Protocols?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

┊风居住的梦幻卍 2024-08-13 18:13:39

我使用与此类似的代码连接到基于 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);

I've used code similar to this to connect to a Sun One-based LDAP to change a user's password. (Shouldn't be that different from 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);
迷爱 2024-08-13 18:13:39

您需要删除密码,然后重新添加。当我这样做时,我使用了 Novell 的 LDAP 库。您可能需要尝试使用 DirectoryEntry 才能使其正常工作。

删除eDirectory - LDAP 通过 ADSI/System.DirectoryServices 中的不可读属性


根据您在 eDirectory 中使用的密码类型,您可能会遇到问题

eDirectory 8.8 的 LDAP/通用密码


如何通过 LDAP 更改 eDirectory 或通用密码
这是 ldif 示例

dn: cn=<myuser>,ou=<myou>,o=<myo>
changetype: modify
replace: userPassword
userPassword: <newPassWord>

You need to remove the password and then re-add it. When I did this I used the LDAP library from Novell. You may have to play around with DirectoryEntry to get it to work.

Deleting non readable attribute from eDirectory - LDAP through ADSI/System.DirectoryServices


you might run into issues depending on the type of password you are using in eDirectory

LDAP / Universal Password with eDirectory 8.8


How to change eDirectory or Universal Password through LDAP
here is an ldif sample

dn: cn=<myuser>,ou=<myou>,o=<myo>
changetype: modify
replace: userPassword
userPassword: <newPassWord>
黄昏下泛黄的笔记 2024-08-13 18:13:39

我同意 Per Noalt 和 Matthew Whited 两人的方法。但其中有一个微妙之处。

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

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

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

I agree with the approaches of two of Per Noalt and Matthew Whited. But there is one subtlty of import.

There is a difference between a user password change and an administrative password change.

If you replace the userPassword, that is an Admin password change, and depending on password policies, might expire the password right away. (eDir uses password expiry, and then a count of grace logins).

If you provide the old and new password, then you are doing a user initiated password reset.

白首有我共你 2024-08-13 18:13:39

书中有一个使用 System.DirectoryServices.Protocols 更改用户密码和管理密码的代码示例 目录服务编程的 .net 开发人员指南。我认为出于版权原因我无法在此处粘贴代码示例,但如果您有兴趣使用 System.DirectoryServices.Protocols 和 System.DirectoryServices,我建议您购买这本书。

There is a code example for both user changing password and administrative password change using System.DirectoryServices.Protocols in the book the .net developer's guide to directory services programming. I assume that I can't paste the code example here for copyright reasons but I can recommend buying the book if you are interested working with System.DirectoryServices.Protocols and System.DirectoryServices.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文