From: [email protected]
[mailto:[email protected]] On Behalf Of
Campbell, Scott
Sent: 08 June 2009 13:58
To: [email protected]; [email protected]
Subject: RE: Perl / CGI and IIS6
> Anthony, I wrote a little method for my libraries which I use to
authenticate all of my web-based apps off of
> Active Directory (LDAP).
> You will need to use the Net::LDAP module. This works on all
platforms.
>
> Hope this helps,
> Scott
>
Sorry to be picky when you are trying to help somebody, but I have a
couple of issues with your code.
> *******************************************************
> =item B<ldap_authenticate()>
>
> This method accepts a username, password, and an array of LDAP
servers, in that order. It returns a true/false > code, and a message.
> IE: ldap_authenticate("[email protected]","MYPass",@dc_list)
That example call doesn't appear to match the parameters in the sub
below.
>
> =cut
>
> sub ldap_authenticate{
> my($class,$username,$password,@ldap_servers)=...@_;
>
> #LDAP Connect#
> my $ldap = Net::LDAP->new(\...@ldap_servers, async => 1);
>
> if(!$ldap){
> return("0","LDAP ERROR! Cannot
connect to LDAP server(s).");
> }
> else{
> #If LDAP servers are listening,
attempt BIND (Authentication)#
> my
$msg=$ldap->bind("$username",password=>"$password");
Try to avoid useless quoting. See 'perldoc -q quoting'
>
> if($msg->error=~m/success/i){
> $ldap->unbind;
> return(1,"Successful
Logon");
> }
> else{
> $ldap->unbind;
> return(0,"Error: " .
$msg->error);
> }
> }
> }
> *******************************************************
HTH
--
Brian Raven
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient or have received this e-mail in error, please advise
the sender immediately by reply e-mail and delete this message and any
attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs