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;
}
}