Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl use CGI; use Net::LDAP qw(:all); use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; print $q->header; if($q->param('looking') eq 'yes'){ $ldap = Net::LDAP->new('ldapserver') or die "$@"; $ldap->bind; # an anonymous bind my $base = "c=us"; my @Attrs = (); my $search = "(&"; if($q->param('first') ne ''){ $search = "$search (givenName=" . $q->param('first') . ")" +; } if($q->param('last') ne ''){ $search = "$search (sn=" . $q->param('last') . ")"; } if($q->param('dept') ne ''){ $search = "$search (Department=" . $q->param('dept') . ")" +; } if($q->param('phone') ne ''){ $search = "$search (telephoneNumber=" . $q->param('phone') + . ")"; } if($q->param('fax') ne ''){ $search = "$search (facsimileTelephoneNumber=" . $q->param +('fax') . ")"; } $search = $search . ")"; $result = LDAPsearch($ldap, $search,\@Attrs); @entries = $result->entries; $ldap->unbind; # take down session } print <<EODUMP; header goes here <form method="post" action=""> <input type=hidden name=looking value=yes> <table width="85%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"><font size="2">Use this form to find a emp +loyee. Enter as much information as you know.</font></td> </tr> <tr> <td width="20%"><font size="2">first Name</font></td> <td width="80%"> <input type="text" name="first" size="25"> </td> </tr> <tr> <td width="20%"><font size="2">Last Name</font></td> <td width="80%"> <input type="text" name="last" size="25" value="$user"> </td> </tr> <tr> <td width="20%"><font size="2">Department Name</font></td> <td width="80%"> <input type="text" name="dept" size="25"> </td> </tr> <tr> <td width="20%"><font size="2">Phone</font></td> <td width="80%"> <input type="text" name="phone" size="25"> </td> </tr> <tr> <td width="20%"><font size="2">Fax</font></td> <td width="80%"> <input type="text" name="fax" size="25"> </td> </tr> <tr align="center"> <td colspan="2"><input type=image src="images/go.gif" widt +h="30" height="20" border=0 alt="submit button"></a></td> </tr> </table> </form> EODUMP PRINTRESULTS(); print <<EODUMP; footer goes here EODUMP sub PRINTRESULTS { print "<table>"; foreach $entr (@entries) { $phone = $entr->get('telephoneNumber'); $user = $entr->get('cn'); $email = $entr->get('mail'); $department = $entr->get('Department'); $address = $entr->get('address'); $address = $address->[0]; $department = $department->[0]; $phone = $phone->[0]; $user = $user->[0]; $email = $email->[0]; $title = $entr->get('title'); $title = $title->[0]; $street = $entr->get('postalAddress'); $street = $street->[0]; print "<tr><td><a href=\"mailto:$email\">$user</a></td>\n +"; print "<td>$phone</td></tr>\n"; print "<tr><td>$department, $title\n</td></tr>\n"; print "<tr><td>$street</td>\n"; print "<tr><td>&nbsp;</td></tr>\n"; } print "</table>"; } sub LDAPsearch { my ($ldap,$searchString,$attrs) = @_ ; my $result = $ldap->search ( base => "$base", scope => "sub", filter => "$searchString", attrs => $attrs, sizelimit => $size_limit ); }

In reply to LDAP Searcher by BigJoe

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (7)
    As of 2018-05-22 07:01 GMT
    Find Nodes?
      Voting Booth?