Active directory ADAM用户';用c重置密码#

Active directory ADAM用户';用c重置密码#,active-directory,ldap,ldap-query,adam,Active Directory,Ldap,Ldap Query,Adam,我正在尝试在ADAM中重置用户passowrd。为此,我使用Accountmanagement名称APCE 我尝试的是: PrincipalContext rootPrincipalContext; LdapConnection objLdapconnection; rootPrincipalContext = new PrincipalContext(ContextType.ApplicationDirectory, host, baseDN, ContextOptions.Negotiate

我正在尝试在ADAM中重置用户passowrd。为此,我使用Accountmanagement名称APCE

我尝试的是:

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,但没有任何效果


我需要提供加密密码吗?或者我需要设置任何属性吗?提前谢谢。

我找到了解决办法。移除

ContextOptions.Negotiate 
实例化
rootprincipalContext

SetPassword()之前使用
ExpirePasswordNow()
方法