【发布时间】:2011-08-09 19:24:24
【问题描述】:
我正在尝试设置属性以解锁 AD 中的用户帐户,并且我正在使用以下代码;问题是 de 不包含 userAccountControl 并且代码失败。
我可以使用DirectorySearcher 获得userAccountControl 的值,但这对我使用de 设置属性没有帮助。有人可以帮我吗?提前致谢
String m_Path = "LDAP://" + distinguishedName;
using (DirectoryEntry de = new DirectoryEntry(m_Path))
{
if (de.Contains("userAccountControl")
{
int m_Val = (int)de.Properties["userAccountControl"][0].Value;
de.Properties["userAccountControl"].Value = m_Val | 0x0001
de.CommitChanges;
}
}
【问题讨论】:
标签: c# .net active-directory