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:
AccountName,
FirstName,
LastName,
AccountNumber.
USER #2:
AccountName,
FirstName,
LastName,
AccountNumber.
After the user is presented with the following formatted results, they can then select #1 or #2, and a line will be built like follows:
AccountName,FirstName,LastName,AccountNumber
I have the following code thus far, but it only works for one result, and disregards any other results...
$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";
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.
Any clarification, please ask! Thank you all.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.