3
我想設置屬性以解鎖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;
}
}