473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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
3 2509

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rahul Apte | last post by:
How do I programmatically check whether ASP and Server Side Includes sub-components of the World Wide Web service are installed on a Windows 2003 Box? I want to do these checks as pre-install...
4
by: Colleyville Alan | last post by:
I have 2 command buttons on a form. I want the first one to be enabled and the second one to be disabled when the form is opened. That works fine. Then, after the user has pressed the first...
5
by: Leo J. Hart IV | last post by:
Hello, I'm hoping someone can help me out. I was wondering if the Enabled property of a CheckBox or RadioButton server control is stored in the ViewState. If not, is there some way to to add...
1
by: H. Williams | last post by:
Is it possible to determine if the Back Button on the browser is enabled? I need to know if the page was called in a new window (for example with HREF target='_blank' or by clicking 'Open in New...
1
by: Mateo | last post by:
Hi, is there a way to display a disabled radiobutton as enabled? (without enabling it of course). In other words, how can I lock a radiobutton without dimming it? My problem is that when the...
7
by: Noozer | last post by:
I have a timer on a form. It isn't firing at all. I know that the timer is enabled, and that the interval is low (4000, which should be 4 seconds). To ensure the timer wasn't being inadvertantly...
4
by: Phill. W | last post by:
Here's a knotty little problem. I have some nasty little controls that needs to behave in a non- windows-Standard way - don't ask why; it's a large application being converted from some older...
2
by: James | last post by:
vb.net 2003 i read the msdn documentation on Const ADS_UF_ACCOUNTDISABLE = &H2 how do i use the above to determine whether my account is disabled ? The following does not work. select case...
2
by: JamesB | last post by:
Hi all. I have a Winforms app that installs a service programatically (as opposed to using InstallUtil). If UAC on Vista is disabled, it works fine. Likewise, if the program is started by...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.