本文介绍了如何使用System.DirectoryServices.Protocols更改密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们的用户存储是所谓的eDirectory LDAP服务器。如何使用System.DirectoryServices.Protocols您更改用户密码?
Our user store is an LDAP server called eDirectory. How do you change user passwords using System.DirectoryServices.Protocols?
推荐答案
我用code类似于这样连接到孙一基于LDAP来更改用户的密码。 (不应从Novell eDirectory的......不同的)
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);
这篇关于如何使用System.DirectoryServices.Protocols更改密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!