From: Christian K. <chr...@ec...> - 2002-11-28 10:25:38
|
hello list=20 i=B4m a perl newbie and i need help!! i would connect to a ldap server check username and password in if ok=20 redirect to a other side i write this script but it don=B4t work #!/usr/bin/perl -w use CGI; use CGI::Carp qw(fatalsToBrowser); use Net::LDAP; my $ldap_host =3D "192.168.10.202" ; my $ldap_port =3D 389 ; my $ldap_base =3D "o=3Decontec, c=3Dde"; my $dn =3D ""; my $pwd =3D "" ; my $query =3D new CGI; print $query->header('text/html'), $query->start_html(-title=3D>'Login'), $query->h1("Bitte Name und Passwort angeben"); if ( = ($name=3D$query->param('name'))&&($pwd=3D$query->param('passwort'))) { $ldap =3D new Net::LDAP('192.168.10.202'); $mesg =3D $ldap->bind($dn =3D> $name,pwd =3D> $passwd, version =3D> 3) = || die "Could not bind to LDAP server" ; if ($mesg->code) { warn $mesg->error; } else {=20 &DisplayResult($mesg); $ldap->unbind(); } } else { my $action =3D $query->url; print $query->startform(-method =3D> 'POST', -action =3D> $action, ); print "<TABLE border=3D0>\n"; print "<TR><TD>Name</TD>"; print "<TD>",$query->textfield('name',"",50), "</TD>"; print "<TD>Passwort</TD>"; print "<TD>",$query->textfield('passwort',"",50),"</TD> </TR></TABLE>"; print $query->br(); print $query->submit(); print $query->endform(); } print $query->end_html(); ########################################################## # Hilfsfunktionen ########################################################## sub DisplayResult { printf("Search did not return any result\n"); #redirect } |