Solved

ldap specify an OU

Posted on 2009-05-13
3
566 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

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm sure that every Windows systems administrator has written, or at least used, a batch or VBS login script at some point in their career, whether it is to map network drives, install printers, or set some user preferences.  No more! With Window…
[b]Ok so now I will show you how to add a user name to the description at login. [/b] First connect to your DC (Domain Controller / Active Directory Server) SET PERMISSIONS FOR SCRIPT TO UPDATE COMPUTER DESCRIPTION TO USERNAME 1. Open Active …
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

948 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

21 Experts available now in Live!

Get 1:1 Help Now