Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ldap specify an OU

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

[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 article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
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…

808 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