Solved

Print list of users in LDAP group with perl

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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.…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

778 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