title: Unlocking user Account
body: <p>I am trying to set properties to unlock User accounts in AD and I am using the following code; the problem is that <code>de</code> does not contain <code>userAccountControl</code> and the code fails. </p>
  
  <p>I can get the value of <code>userAccountControl</code> by using <code>DirectorySearcher</code> but that does not help me in setting the property using <code>de</code>. Could anyone please help me? Thanks in advance</p>
  
  <pre><code>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;
     }
  }
  </code></pre>