DirectoryEntry Enabled

I need to check whether an account in the active directory was enabled.

After some searching, I came to understand that the enabled feature is not only for User but for every node in the active directory. That means every DirectoryEntry instance.

Here is how you check if it is enabled

public const string 
AccountControl="userAccountControl"; public const int EnabledFlag= 0x2;
static bool IsEnabled(DirectoryEntry de)
{
  return (((int)
  de.Properties[AccountControl].Value)
  & EnabledFlag) == 0;
}
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s