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

AD ObjectCategory=Computer - How to find out if the computers are Active?

P: n/a
Hi.

I'm developing a testapplication, retrieving objects of type "Computer"
from out AD server. More than 5000 are listed, and I know lots of these
are set as inactive.

I've seen some code testing if user objects are active or not:
DirectoryEntry de = searcher.FindOne().GetDirectoryEntry();
int UAC =
Convert.ToInt32(de.Properties["userAccountControl"].Value);
bool _DSEnabledAccount = (UAC &
(int)ADS_USER_FLAG.ADS_UF_ACCOUNTDISABLE) != 0;

if (_DSEnabledAccount == true)
lbxGetComputerNamePropValues.Items.Add("Computer active");
else
lbxGetComputerNamePropValues.Items.Add("Computer inactive");
I strongly believe that the value retrieved from userAccountControl is
related to users, not computers... If I run the code above ALL
computers are listed as inactive.

Has anyone coded something around computer objects and checked if the
computer objects are active?

Help is greatly appreciated.

Fritjolf

Sep 26 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
See inline.

Willy.

"Fritjolf" <Mo*************@edb.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
| Hi.
|
| I'm developing a testapplication, retrieving objects of type "Computer"
| from out AD server. More than 5000 are listed, and I know lots of these
| are set as inactive.
|
| I've seen some code testing if user objects are active or not:
| DirectoryEntry de = searcher.FindOne().GetDirectoryEntry();
| int UAC =
| Convert.ToInt32(de.Properties["userAccountControl"].Value);
| bool _DSEnabledAccount = (UAC &
| (int)ADS_USER_FLAG.ADS_UF_ACCOUNTDISABLE) != 0;
|
| if (_DSEnabledAccount == true)
| lbxGetComputerNamePropValues.Items.Add("Computer active");
| else
| lbxGetComputerNamePropValues.Items.Add("Computer inactive");
|
|

There is a bug in this code: true is returned when
ADS_USER_FLAG.ADS_UF_ACCOUNTDISABLE is set in UAC, that means that true
means DISABLED.
Note that this doesn't mean that the machine (or whetever) account is
active, it only means that he is enabled. He may even be non existant.

| I strongly believe that the value retrieved from userAccountControl is
| related to users, not computers... If I run the code above ALL
| computers are listed as inactive.
|
userAccountControl is for users as well as for computers.
| Has anyone coded something around computer objects and checked if the
| computer objects are active?
|
| Help is greatly appreciated.
|
| Fritjolf
|
Sep 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.