How do I programatically read the enabled or disabled
status of accounts?
Have read the msdn article:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/sds/sds/enabling_and_disabling_the_user_account.asp
The following code example shows how to enable a user
account.
[C#]
DirectoryEntry usr =
new DirectoryEntry("LDAP://CN=New
User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties
["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val &
~ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();
The following code example shows how to disable a user
account.
[C#]
DirectoryEntry usr =
new DirectoryEntry("LDAP://CN=Old
User,CN=users,DC=fabrikam,DC=com");
int val = (int) usr.Properties
["userAccountControl"].Value;
usr.Properties["userAccountControl"].Value = val |
ADS_UF_ACCOUNTDISABLE;
usr.CommitChanges();