By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,745 Members | 1,897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,745 IT Pros & Developers. It's quick & easy.

How do you prgramatically determine whether AD accounts are disabled or enabled?

P: n/a
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();

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.