List Info

Thread: C-Sharp (C#) Group: List servers in Active Directory




C-Sharp (C#) Group: List servers in Active Directory
user name
2006-01-13 15:55:31
I need to return a list of servers and domain controllers
from active
directory. This is what I have:

 DirectoryEntry ADEntry = new
DirectoryEntry("LDAP://myDomain");
                     DirectorySearcher ADSearcher = new
DirectorySearcher(ADEntry);
                     ADSearcher.Filter =
"(&(objectCategory=computer))";

The above works and will return all computers.

How do I narrow it down to return the servers? How to
narraow it down
to return domain controllers?

I tried changing the ADSearch.Filter to
"(&(objectCategory=group)(ou=Domain
Controllers))";

This didn't work. 

Thanks!

C-Sharp (C#) Group: Re: List servers in Active Directory
user name
2006-01-19 14:40:46
Hi

Try this to list Domain Controllers:

ADSearcher..Filter = ("(primaryGroupID=516)");

neteng451 wrote:
> I need to return a list of servers and domain
controllers from active
> directory. This is what I have:
>
>  DirectoryEntry ADEntry = new
DirectoryEntry("LDAP://myDomain");
>                      DirectorySearcher ADSearcher = new
> DirectorySearcher(ADEntry);
>                      ADSearcher.Filter =
> "(&(objectCategory=computer))";
>
> The above works and will return all computers.
>
> How do I narrow it down to return the servers? How to
narraow it down
> to return domain controllers?
>
> I tried changing the ADSearch.Filter to
> "(&(objectCategory=group)(ou=Domain
Controllers))";
> 
> This didn't work. 
> 
> Thanks!

C-Sharp (C#) Group: Re: List servers in Active Directory
user name
2006-01-20 12:55:56
That works, but it only returns one Domain Controller - the
primary DC.
Is there a way to get the secondary DC as well?

Thank you for your help.

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )