Solved

Print list of users in LDAP group with perl

Posted on 2010-08-22
3
1,522 Views
Last Modified: 2012-06-21
Hi

I have a redhat system that uses LDAP. I have very little experience with LDAP and was trying to figure out how the groups work. I managed to retrieve list of of users with perl-ldap cm\ommands and then saw that the groups I,ve been looking for are actually also listed there.
Users have a ou=users and the groups have ou=groups.

Is there a way now to retrieve a list of users that belong to a specific group like "Students" with perl-ldap and print it to a file?
0
Comment
Question by:QuintusSmit
[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 7

Expert Comment

by:mcuk_storm
ID: 33495507
You should just need to do another query like you presumably are to get the user list, you can run this within the scope of your users OU to increase efficiency, or a top level sub tree search.

The query should look something like:
(&(objectClass=user)(memberOf=CN=TestG123,OU=Groups,DC=TESTDOM,DC=local))

Where CN=TestG123,OU=Groups,DC=TESTDOM,DC=local is the Distinguished name (DN) of the group you want to get the members for.

0
 
LVL 7

Accepted Solution

by:
mcuk_storm earned 500 total points
ID: 33495524

$mesg = $ldap->search(
    base  => "OU=Users,DC=TESTDOM,DC=local",
    filter => "(&(objectClass=user)(memberOf=CN=TestG123,OU=Groups,DC=TESTDOM,DC=local))",
    scope => 'sub'
);

Open in new window

0
 
LVL 1

Author Comment

by:QuintusSmit
ID: 33498380
I will have a look - it seems to be what I am looking for.
tx
0

Featured Post

Stack Overflow Podcast - Frustrating Miracles

In this podcast, Stack Overflow interviewed Linux Academy CEO/Founder, Anthony James, and got his developer story!

"Follow your passion, be prepared to work hard and sacrifice, and, above all, don't let anyone limit your dreams."  - Donovan Bailey

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Six Sigma Control Plans
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

626 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