DirectoryEntry服务器不支持CommitChanges()

时间:2014-06-06 11:14:36

标签: c# .net active-directory

我尝试使用以下c#代码更改AD中的用户属性:

DirectoryEntry root = new DirectoryEntry("LDAP://xxx/DC=xxx,DC=xx,DC=xx", "xxx", "xxx");          
DirectorySearcher directorySearcher = new DirectorySearcher(root);

directorySearcher.Filter = "(&(objectclass=user)(|(cn=Users)(cn=user001)))";

SearchResult sResultSet = directorySearcher.FindOne();
string a = (GetProperty(sResultSet, "badPwdCount"));

DirectoryEntry ADuser = new DirectoryEntry(sResultSet.Path, "xxx", "xxx");
ADuser.Properties["badPwdCount"].Value = 3;
ADuser.CommitChanges();
ADuser.Close();

我能够阅读该值并浏览AD,但我无法提交更改。每次执行ADuser.CommitChanges();时,我都会收到以下错误:

  

System.DirectoryServices.DirectoryServicesCOMException:服务器是   无法处理请求。

我的帐户是域管理员组的一部分,我拥有所有访问权限。 可能是什么错误?是安全问题还是框架/服务器不兼容?

1 个答案:

答案 0 :(得分:2)

badPwdCount是一个特殊属性,在域控制器之间是唯一的,无法以任何方式手动更改。

如果您想更改此值,因为此值为NULL的用户会导致您出现问题,请在此处查看我的答案:

Active Directory property "badPwdCount"

否则,回到绘图板......