Yes. Correct
On Mon, Nov 9, 2009 at 7:30 AM, Ashley M. Kirchner <[email protected]>wrote:
>
> 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
>
>
--
Devendra Jadhav
देवेंद्र जाधव