Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Print list of users in LDAP group with perl

Posted on 2010-08-22
3
Medium Priority
?
1,594 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 2000 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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

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.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

704 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