walkingthecow has asked for the wisdom of the Perl Monks concerning the following question:
Hey all, I am just trying to figure out how format the results for an LDAP search query using Net::LDAP. I am searching for users by name, and when I get more than one result I would like to display them all (present them to the user) in the following format:
USER #1:Now, this is perfect if there is one user, and if there is only one user this is how I want it, but trying to figure out how to display it for multiple results, and allow user to select one result out of multiple.$mesg = $ldap->search( # perform a search base => "OU=BLA,DC=yum,DC=bum,DC=sum,DC=tum", filter => "(&(objectClass=user)(objectCategory= +person)(AccountType=805306368)( firstName=Dan*)(lastName=Jones))", attrs => [ 'firstName', 'lastName', 'accountNam +e', 'accountNumber' ] ); $mesg->code && die $mesg->error; foreach $entry ($mesg->entries) { $firstName = $entry->get_value("firstName"); $lastName = $entry->get_value("lastName"); $accountName = $entry->get_value("accountName"); $accountNumber = $entry->get_value("accountNumber"); } print "$firstName $lastName,$accountName,$accountNumber\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl-ldap formatting question
by sflitman (Hermit) on Jan 08, 2009 at 05:07 UTC |