gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 18:19:07 24 4
gpt4 key购买 nike

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

最佳答案

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

关于c# - 如何使用System.DirectoryServices.Protocols更改密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1544336/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com