Solved

ldap specify an OU

Posted on 2009-05-13
3
563 Views
Last Modified: 2012-06-22
How can i specify  a speciffic ou  and  an speciffic group in an ldap string?

Thanks
0
Comment
Question by:bekosysadmin
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Wardy_01
ID: 24372786
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 :)
0
 
LVL 27

Accepted Solution

by:
bluntTony earned 500 total points
ID: 24374342
If you just want the pure LDAP as it would be passed to ADSI, then...

;(&(objectCategory=group)(cn=));distinguishedName;onelevel

This says 'search the OU MyOU for groups called  and return me the DN of this group, and don't search sub-OUs'




0
 
LVL 4

Expert Comment

by:Wardy_01
ID: 24374520
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 :)
0

Join & Write a Comment

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now