From: Jim H. <ha...@us...> - 2001-04-18 12:41:58
|
For your specific application, I found that it is best to keep a .dbm of used or unused uid numbers and select one based on that after verifying against the directory to make sure that the 2 are in sync. We have about 8000 uids with a turnover of about 2000 / year. My first thought was to do something similar to what you have shown below, but decided that it was too inefficient. --Jim Harle On Wed, 18 Apr 2001 mur...@po... wrote: > Hi, > I find the Net::LDAP very helpful in my work, I have a couple of questions > though- > > Q1. the structure returned by as_struct a bit cumbersome for my normal use- > use of the DN as a key, hashref to data in array even when only one value is > present. I understand why it is that way, it is just over the top for the > data I am working with and I find myself looping over the results of a > search and dropping the returned values into a hash using the UID as a key > (I know this will be unique as it is an employee ID string)- > > # this is what I am doing now- > sub get_ldap_data { > my @attrs = @_; > my $mesg = $ldap_obj->search ( > attrs => [@attrs], > base => "ou=people,dc=domain,dc=com,dc=au", > filter => "(uid=*)", > ); > $mesg->code && die $mesg->error; > foreach my $entry ($mesg->all_entries) { > $uid = $entry->get_value('uid'); > # etc. > $highest_uid = $uidnumber if ($uidnumber > $highest_uid); > @{$ldap{$uid}} = ($uidnumber, .....); > } > return %ldap; > } > > Is there any way to process the search results as they are found, this would > let me create my own structure on the fly and also enable me to look for > other conditions such as highest used uidnumber as I go, something like > foreach my $entry ($ldap_obj->search()){ > .... > } > Or is there a better way to approach the problem? > > Q2. is there a way to get a search to halt as soon as an item matching the > search criteria is found? > > Thanks for the help, > regards > Murray > > -- > Murray Barton > Unix Systems Administrator > Western Australian Police Service > Tel: (08) 9222 1900 > Fax: (08) 9222 1698 > > > ************************************************************************************************ > This email message and any attached files may contain information that is > confidential and subject of legal privilege intended only for use by the individual > or entity to whom they are addressed. If you are not the intended recipient or the > person responsible for delivering the message to the intended recipient be > advised that you have received this message in error and that any use, copying, > circulation, forwarding, printing or publication of this message or attached files is > strictly forbidden, as is the disclosure of the information contained therein. > If you have received this message in error, please notify the sender immediately > and delete it from your Inbox. > ************************************************************************************************ > > |