develooper Front page | perl.ldap | Postings from April 2010

Remove list of users from a group

Thread Next
From:
Danny Burkland
Date:
April 7, 2010 16:50
Subject:
Remove list of users from a group
Message ID:
l2v1414b5041004071649se1a5a10bpd0e510acb18d81b8@mail.gmail.com
Hello all,

I am new to the Net::LDAP module (and Perl in general) however I have
quickly learned the basics of OO programming with Perl. I currently have
been working on a script that is supposed to take a list of users (one
username per line) and remove them from a defined group on an OpenLDAP
server. My current method for achieving this goal is as follows:

a) Lookup $group on the LDAP server to make sure it exists
b) If the group exists, I then have the script open the input file (Defined
by $ARGV[0])
c) Set contents of input file equal to an array (chomp newline characters
off each element)
c) For each line in the input array, resolve the user's DN by performing a
search (uid=$_)
d) If the user is found, then remove the individual from the ldap directory

While I figured that a user sometimes will exist on the LDAP server however
not be a member of $group, I added the functionality to determine membership
by use of status code for the modification. While this seems to work I am
wondering if there is a better way to structure my script? Is it possible to
search a group's attributes for the user's entry and then some how store
that attribute's value as a scalar? I will happily post my current code if
requested. Thanks again!

Dan


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About