467,169 Members | 984 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,169 developers. It's quick & easy.

How do I programatically determine the enabled or disabled status of AD accounts

How do I programatically determine the enabled or
disabled status of AD accounts?

I have queried the userAccountControl key, but all I get
back is an int, and it seems to be the same for enabled
or disabled accounts. Please help.

I have read the following 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();

Nov 15 '05 #1
  • viewed: 2310
Share:
3 Replies

"dave" <an*******@discussions.microsoft.com> wrote in message
news:13****************************@phx.gbl...
How do I programatically determine the enabled or
disabled status of AD accounts?

I have queried the userAccountControl key, but all I get
back is an int, and it seems to be the same for enabled
or disabled accounts. Please help.


Should be different, what value did you get back?
Wily.
Nov 15 '05 #2
512 for enabled and disabled accounts
-----Original Message-----

"dave" <an*******@discussions.microsoft.com> wrote in messagenews:13****************************@phx.gbl...
How do I programatically determine the enabled or
disabled status of AD accounts?

I have queried the userAccountControl key, but all I get back is an int, and it seems to be the same for enabled
or disabled accounts. Please help.


Should be different, what value did you get back?
Wily.
.

Nov 15 '05 #3
OK, I'm an idiot, 512 for enabled accounts and 514 for
disabled, don't bother replying as I have fixed my own
stupidity. LOL.
-----Original Message-----
512 for enabled and disabled accounts
-----Original Message-----

"dave" <an*******@discussions.microsoft.com> wrote in

message
news:13****************************@phx.gbl...
How do I programatically determine the enabled or
disabled status of AD accounts?

I have queried the userAccountControl key, but all Iget back is an int, and it seems to be the same for enabled or disabled accounts. Please help.


Should be different, what value did you get back?
Wily.
.

.

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by H. Williams | last post: by
1 post views Thread by Mateo | last post: by
4 posts views Thread by Phill. W | last post: by
2 posts views Thread by James | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.