bionicle32 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl Guru's It is I Bionicle32 the confused Perl programmer. I am having an issue with a login script. What I want the script to do is to have two textfields displayed via HTML parsed back to the browser if no parameters have been sent. Once the user fills out the form with their UID and PASSWORD I am then trying to make a successful bind using their supplied user id and password.
## Connect and bind to the server. $ldap = Net::LDAP->new("servername.com",port => 389,version => 3 ) or +die $!; my $result = $ldap->bind("id=$uid, o=intra, ou=people, dc=xxxx, dc=xxx +", password => $pswd); if ($result->code != LDAP_SUCCESS) { die $result->error(); # Authentication failed }
What I am wondering is if my bind is bad code? This is the error sent back to the browser.
Software error: No such object at login2.cgi line 46.
Which is the if statement for LDAP_SUCCESS. If indeed this is incorrect syntax why and why would I use dn => to start my bind instead of the way I did it above? When I use double qoutes around uid like this $ldap->bind("uid=$uid"," o=intra, ou=people, dc=xxxx, dc=xxx", password => $pswd); my script works. Is this because I am doing an anonymous bind? All I want to do in short is validate that the user logging into my application is who they say they are. If I have not supplied enough information above please say so and I will explain further so you could help me. I appreciate all of you guys help in the past because your suggestions have helped me in becoming a more knowledgable programmer. -Bionicle32

Replies are listed 'Best First'.
Re: LDAP Bind Confusion
by tachyon (Chancellor) on Dec 14, 2003 at 21:14 UTC
    use Win32::AuthenticateUser; AuthenticateUser("domain", "user", "passwd");

    As for the LDAP question your LDAP syntax looks odd. Do C:\> ldifde -f dump.ldap to dump your AD contents to a file and have a look at the formatting of a standard user descriptor. There is some sample code here that uses Net::LDAP for Authentication.

    cheers

    tachyon

      Tachyon, I have a quick question for you. I am using a web form to get the login information from the user. I noticed that you said use Win32::AuthenticateUser at the top of your code. Can this module be used on a Unix box? Thanks - Bionicle32
        Win32::AuthenticateUser ... Can this module be used on a Unix box?

        Nope.