Connect to LDAP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




   Hi folks,

I've never done any PHP->LDAP code writing (nor have I ever dealt with an LDAP server to begin with.) However I'm writing an app which requires verifying a user's credentials against an LDAP server. The admin of the server sent me the following snippet, however also made it clear that he is not 100% whether it's accurate (he's not a PHP coder). And I don't have remote access to the server (the app is going to sit on the internal network and the LDAP server doesn't accept outside connections.)

So, asking the wise folks on here, does the following piece look semantically correct?

        /* Check against LDAP server */
        $adServer = "server.address.hidden";
$ldapconn = ldap_connect($adServer) or die("Connection to the AD server failed.");
        $ldapuser = $_POST["uname"];
        $ldappass = $_POST["pword"];
        $ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappass);

        if ($ldapbind) {
          $msg = "User Authenticated Successfully!";
          $_SESSION['username'] = $ldapuser;
          $_SESSION['password'] = $ldappass;
          return true;
        } else {
          $msg = "Invalid username / password";
          return false;
        }

   Thanks.

   -- A

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux