Hello,
Here's some code:
DirectorySearcher searcher = new DirectorySearcher();
searcher.Filter = "(&(objectClass=user)(sAMAccountName=" + lstUsers.SelectedItem.Text + "))";
SearchResult result = searcher.FindOne();
Within result.Properties["useraccountcontrol"] will be an item which will give me a value depending on the state of the account. For instance, a value of 66050 means I'm dealing with: A normal account; where the password does not expire;which has been disabled. Explanation here.
What's the most concise way of finding out if my value "contains" the AccountDisable flag (which is 2)
Thanks in advance!