I (think) I want to use a BItWise Operator to check useraccountcontrol property!
bitwise-operators, c#, ldap
Solution
Convert.ToBoolean((int)result.Properties["useraccountcontrol"] & 0x0002)
Translated from a current code base here, it should work...
Problem
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!