From: Mark W. <mew...@un...> - 2000-10-06 13:40:58
|
You might want to look at the "printMembers.pl and ismember.pl" scripts in the contrib directory. Mark On Fri, 6 Oct 2000, Padraig Ryan wrote: > Hi, > > Does anyone have a code snippet that will enumerate the groups from an ldap > server. > > I have the follwing but am a bit stuck...Thanks. > > Padraig > > ############################################## > ## Funtion to return All Groups from Ldap ## > ############################################## > > sub Get_Groups { > > # Arguments to be passed in the following format.. > # &Get_Groups; > > $ldap=Net::LDAP->new($Ldap_Server) or die 'Problem with Ldap $@'; > $Filter='(&(cn=*)(objectClass=groupOfUniqueNames))'; #search for all > Groups > > $result=&Search_Ldap($Search_Base, $Filter); > print "<BR>====DEBUG==== result of group search=".$result if $DEBUG; > > @entries = $result->all_entries; #Store all found groups in table, > print "<BR>====DEBUG==== entries=".@entries if $DEBUG; > > foreach (@entries) { > $ptr = $_->get('Name'); > $i = 0; > foreach $member (@$ptr){ #store each memberid in table > @memberData = split(/,/, $member); > $memberData[0] = substr($memberData[0], 4); > print "<BR>====DEBUG==== Groups=".$Groups[$i] if $DEBUG; > > $Groups[$i] = $memberData[0]; > $i++; > } > } > return $Groups; > } > > > ---------------------------------------------------------------- > Padraig Ryan > IT Manager > Institute of Technology, Sligo > Ireland > > P +353(0)71.55365 > F +353(0)71.60475 > M +353(0)87.2334062 > E rya...@it... > W http://www.itsligo.ie/staff/pryan > > > |