Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ldap specify an OU

Posted on 2009-05-13
3
Medium Priority
?
586 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
[X]
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
  • 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
It’s time for spooky stories and consuming way too much sugar, including the many treats we’ve whipped for you in the world of tech. Check it out!
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

609 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