473,396 Members | 2,013 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,396 software developers and data experts.

Accessing AD ObjectCategory=Computer

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
DirectoryEntry("LDAP://DC=DomainName,DC=local");
DirectorySearcher mySearcher = new DirectorySearcher(myDirEntry);
mySearcher.Filter =
string.Format("(&(objectCategory=computer))");
foreach (SearchResult myResult in mySearcher.FindAll())
{

lbxGetComputersDirSearcher.Items.Add((string)myRes ult.Properties["name"][0]);
}

This code lists the computername of 5500 computers (with pagesize and
sizelimit also set in the searcher object).

A object of type computer has (from what I can see) 35 properties.

Here is the (most likely) simple thing I can't manage:
How do I iterate through a Computer object and just write the property
names to a listbox? It should be easy with the use of a foreach loop.
Something like:
foreach (string propertyName in ComputerObject
{
lbxPropNames.Items.Add(propertyName);
}

But I just can't figure out the syntax.
And yes, I am new to C# (although not new to programming)

Help is GREATLY apreciated!!!

Thanx,

Fritjolf

Sep 25 '06 #1
2 3853

"Fritjolf" <Mo*************@edb.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
| 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
| DirectoryEntry("LDAP://DC=DomainName,DC=local");
| DirectorySearcher mySearcher = new DirectorySearcher(myDirEntry);
| mySearcher.Filter =
| string.Format("(&(objectCategory=computer))");
| foreach (SearchResult myResult in mySearcher.FindAll())
| {
|
|
lbxGetComputersDirSearcher.Items.Add((string)myRes ult.Properties["name"][0]);
| }
|
| This code lists the computername of 5500 computers (with pagesize and
| sizelimit also set in the searcher object).
|
| A object of type computer has (from what I can see) 35 properties.
|
| Here is the (most likely) simple thing I can't manage:
| How do I iterate through a Computer object and just write the property
| names to a listbox? It should be easy with the use of a foreach loop.
| Something like:
| foreach (string propertyName in ComputerObject
| {
| lbxPropNames.Items.Add(propertyName);
| }
|
| But I just can't figure out the syntax.
| And yes, I am new to C# (although not new to programming)
|
| Help is GREATLY apreciated!!!
|
| Thanx,
|
| Fritjolf
|

foreach(SearchResult myResult in res) {
foreach( string propName in myResult.Properties.PropertyNames)
{
lbxGetComputersDirSearcher.Items.Add(propName);
....

Willy.

Sep 25 '06 #2
Thanx!
I did try:
foreach( string propName in
myResult.Properties.PropertyNames.ToString())
but that gave me a compile error.

Thanx!!!

foreach(SearchResult myResult in res) {
foreach( string propName in myResult.Properties.PropertyNames)
{
lbxGetComputersDirSearcher.Items.Add(propName);
...

Willy.
Sep 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different...
5
by: Neil | last post by:
I am aiming to creat an ASP.NET webpage that will communicate with a database on the users computer. the user will go to my site, select his db from his computer and my webapge will run an algorithm...
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...
2
by: Vincent | last post by:
I have been trying to find some API routines that will allow me to determine the name of the computer that is accessing a file on a server. I have found the NetFileEnum call (returns the names of...
1
by: Fritjolf | last post by:
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...
6
by: MattPKaiser | last post by:
I am trying to find a way to check if a computer on a network is "online" so that I can access a file on a share. In short I maintain a list of computers that have my service running (in the...
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...
0
by: kingkongpennock | last post by:
Hi there, i have a frustrating problem on my hands. at first i had nero 8 ultra, but realized i did not need it any more. so i did the usual thing and tried to uninstall it. all was going...
1
by: vabh | last post by:
Hello, My computer is connected in LAN and so many other computers too. So, now i want to access any .exe file of any other computer. Before that i am accessing the Computer Name and IPAddress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.