473,385 Members | 1,890 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,385 software developers and data experts.

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

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

Similar topics

10
by: huzz | last post by:
I have web application that quaries the Active Directory to get user details.. everything works fine but someday I'll get System.Runtime.InteropServices.COMExection and if I restart the client...
12
by: JIM.H. | last post by:
Hello, Here is my code that I got from internet and I am assuming this give me e-mail address of the people in the active directory. Private Sub Page_Load(ByVal sender As System.Object, ByVal e...
0
by: Julien | last post by:
Hello I am now building an appli using the "System.DirectoryServices" namespace in order to retrieve particular data from my Active Directory I'd like to get the computer RDN of all the computers...
10
by: LittlePython | last post by:
I am have trouble finding a simple working example of using ADO to search Active Directory. I am hoping someone could point me to a generic working script that connects to AD and pulls up a...
2
by: Fritjolf | last post by:
Hi. I've written some code to list objects of type "Computer" from our firms primary AD controller. The code is simple: DirectoryEntry myDirEntry = new...
0
by: bcanter | last post by:
I found a file on the web that will allow you to enumerate groups but it was an .hta and the top level admins won't allow this. I need to give managers access to the groups so that when a new user is...
0
by: Phylum | last post by:
Hi all. Just signed up today and I was hoping to simplify a task I'm sure we may all benefit from. I thank you in advance for clicking on this post! I want to warn you that I'm no coding guru - I...
1
maxamis4
by: maxamis4 | last post by:
Hello folks, Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the...
2
by: Jim in Arizona | last post by:
I'm trying to do a check to see if a specific active directory user account exists in active directory AND a specific group. I can't seem to get the filter down right. I can do this to find a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.