我正在尝试在ADAM中重置用户passowrd。为此我使用Accountmanagement namesapce
我尝试了什么:PrincipalContext rootPrincipalContext;
LdapConnection objLdapconnection;
rootPrincipalContext = new PrincipalContext(ContextType.ApplicationDirectory, host, baseDN, ContextOptions.Negotiate, username, password);
LdapDirectoryIdentifier identifier = new LdapDirectoryIdentifier(host, Convert.ToInt32(port));
NetworkCredential credential = new NetworkCredential(username, password);
LdapConnection ldapCon = new LdapConnection(identifier, credential);
ldapCon.AuthType = AuthType.Negotiate;
objLdapconnection = ldapCon;
用于密码重置:
UserPrincipal existingUsr = UserPrincipal.FindByIdentity(rootPrincipalContext, IdentityType.DistinguishedName, "cn=" + inputName + ",ou=gslab,dc=starfish");
existingUsr.SetPassword(userPassvalue); this lines throws exception "directory property can not be found"
我检查过没有字符串是空的,也尝试过contextOption.secureSocketlayer但没有任何作用
我需要提供加密密码吗?还是我需要设置任何属性?提前谢谢。
答案 0 :(得分:0)
我得到了解决方案。只需删除
ContextOptions.Negotiate
实例化rootprincipalContext
时。
在ExpirePasswordNow()
之前使用SetPassword()
方法。