From: Graham B. <gb...@us...> - 2002-04-23 16:08:01
|
Update of /cvsroot/perl-ldap/ldap/lib/LWP/Protocol In directory usw-pr-cvs1:/tmp/cvs-serv14900/LWP/Protocol Modified Files: ldap.pm Log Message: Patch from ma...@ev... Index: ldap.pm =================================================================== RCS file: /cvsroot/perl-ldap/ldap/lib/LWP/Protocol/ldap.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ldap.pm 16 Aug 2000 11:07:33 -0000 1.2 +++ ldap.pm 23 Apr 2002 16:07:57 -0000 1.3 @@ -1,4 +1,4 @@ -# Copyright (c) 1998 Graham Barr <gb...@po...>. All rights reserved. +# Copyright (c) 1998-2002 Graham Barr <gb...@po...>. All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. @@ -13,6 +13,8 @@ require LWP::Protocol; @ISA = qw(LWP::Protocol); +$VERSION = "1.10"; + use strict; eval { require Net::LDAP; @@ -56,8 +58,7 @@ my $host = $url->host; my $port = $url->port; - my $user = $url->user; - my $password = $url->password; + my ($user, $password) = split(":", $url->userinfo, 2); # Create an initial response object my $response = new HTTP::Response &HTTP::Status::RC_OK, "Document follows"; @@ -65,7 +66,7 @@ my $ldap = new Net::LDAP($host, port => $port); - my $mesg = $ldap->bind; + my $mesg = $ldap->bind($user, password => $password); if ($mesg->code) { my $res = new HTTP::Response &HTTP::Status::RC_BAD_REQUEST, @@ -94,42 +95,41 @@ return $res; } else { - my $content = "<HEAD><TITLE>Directory Search Results</TITLE></HEAD>\n<BODY>"; + my $content = "<head><title>Directory Search Results</title></head>\n<body>"; my $entry; my $index; for($index = 0 ; $entry = $mesg->entry($index) ; $index++ ) { my $attr; - $content .= $index ? "<TR><TH COLSPAN=2><hr> </TR>\n" - : "<TABLE>"; + $content .= $index ? qq{<tr><th colspan="2"><hr> </tr>\n} : "<table>"; - $content .= "<TR><TH COLSPAN=2>" . $entry->dn . "</TH></TR>\n"; + $content .= qq{<tr><th colspan="2">} . $entry->dn . "</th></tr>\n"; foreach $attr ($entry->attributes) { my $vals = $entry->get_value($attr, asref => 1); my $val; - $content .= "<TR><TD align=right valign=top"; - $content .= " ROWSPAN=" . scalar(@$vals) + $content .= q{<tr><td align="right" valign="top"}; + $content .= q{ rowspan="} . scalar(@$vals) . q{"} if (@$vals > 1); - $content .= ">" . $attr . " </TD>\n"; + $content .= ">" . $attr . " </td>\n"; my $j = 0; foreach $val (@$vals) { $val = qq!<a href="$val">$val</a>! if $val =~ /^https?:/; $val = qq!<a href="mailto:$val">$val</a>! if $val =~ /^[-\w]+\@[-.\w]+$/; - $content .= "<TR>" if $j++; - $content .= "<TD>" . $val . "</TD></TR>\n"; + $content .= "<tr>" if $j++; + $content .= "<td>" . $val . "</td></tr>\n"; } } } - $content .= "</TABLE>" if $index; + $content .= "</table>" if $index; $content .= "<hr>"; $content .= $index ? sprintf("%s Match%s found",$index, $index>1 ? "es" : "") - : "<B>No Matches found</B>"; - $content .= "</BODY>\n"; + : "<b>No Matches found</b>"; + $content .= "</body>\n"; $response->header('Content-Type' => 'text/html'); $response->header('Content-Length', length($content)); $response = $self->collect_once($arg, $response, $content) @@ -141,3 +141,5 @@ $response; } + +1; |