Link to home
Start Free TrialLog in
Avatar of bekosysadmin
bekosysadmin

asked on

ldap specify an OU

How can i specify  a speciffic ou  and  an speciffic group in an ldap string?

Thanks
Avatar of Wardy_01
Wardy_01

LDAP paths are simply constructed ...

LDAP:// <-- bit like the http:// bit in a url, specifies the type of transport being used.
LDAP://rootDSE/ <-- gets root path of all LDAP objects on the domain.

LDAP://DC1/OU=Users  <-- get users ou object at the root level of your domain tree using domain controller called "DC1".

Using a .NET language like C# you can do things like this to get a list of the computers on your domain ...

DirectoryEntry ADRoot = new DirectoryEntry("LDAP://DC1");
DirectorySearcher ser = new DirectorySearcher(ADRoot, "(&ObjectCategory=computer)");
SearchResultCollection results = ser.FindAll();

List<string> computers = new Lis<string>();
foreach (SearchResult res in results)
{
    string currentMachine = res.Properties["name"][0].ToString();
    computers.Add(currentMachine);
}

........

in the above example the object results contains a list of WMI objects from the results of the search call on the server "DC1"s active directory.

each result "res" in the collection is an object that represents an active directory entry and has all the properties of that entry including the full AD path.

dropping this code sample in to Visual studio will allow you put a breakpoint inside the loop and hopefully get a cleaner idea of what paths look like.

Good Luck !!!
If you need any more help let me know :)
ASKER CERTIFIED SOLUTION
Avatar of bluntTony
bluntTony
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oooo clean ... i like that ... wish my LDAP was that fluent :)
I normally just talk all C# to my ..NET compiler and let it do the LDAP talk ... lol !

Tony here must be a network admin or something :)