I (think) I want to use a BItWise Operator to check useraccountcontrol property!

Posted by Jim on Stack Overflow See other posts from Stack Overflow or by Jim
Published on 2010-03-16T16:26:37Z Indexed on 2010/03/16 16:41 UTC
Read the original article Hit count: 328

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about c#

Related posts about ldap