private void ChangeUserPassword (string commonName, string oldPassword, string newPassword)
{
try
{
DirectoryEntry de=new DirectoryEntry("LDAP://DC=***,DC=***","ADUser","ADPassword",AuthenticationTypes.Secure);
DirectorySearcher deSearch = new DirectorySearcher(de);
deSearch.Filter = "(&(&(objectCategory=person)(objectClass=user))(cn=" + commonName + "))";
deSearch.SearchScope =SearchScope.Subtree;
SearchResult result = deSearch.FindOne();
DirectoryEntry oUser= new DirectoryEntry(result.Path);
oUser.Invoke("ChangePassword", new Object[]{oldPassword, newPassword});
oUser.CommitChanges();
oUser.Close();
}
catch(Exception ex)
{
//
.
}
}
处出错:
System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.Runtime.InteropServices.COMException (0x8007202F): 出现一个约束冲突。
浙公网安备 33010602011771号