Solved

Print list of users in LDAP group with perl

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Open BDS Pf 3 48
IPA - how do I choose who can log into which servers? 1 68
Virtual Firewall to Filter DHCP Traffic? 23 77
Redirect mail server from IP to IP 2 91
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

862 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

25 Experts available now in Live!

Get 1:1 Help Now