Solved

Print list of users in LDAP group with perl

Posted on 2010-08-22
3
1,347 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

747 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

10 Experts available now in Live!

Get 1:1 Help Now