F
Fritjolf
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)myResult.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
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)myResult.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