views:

291

answers:

1
+2  A: 
<?php

// using ldap bind
$ldaprdn  = 'uname';     // ldap rdn or dn
$ldappass = 'password';  // associated password

// connect to ldap server
$ldapconn = ldap_connect("ldap.example.com")
    or die("Could not connect to LDAP server.");

if ($ldapconn) {

    // binding to ldap server
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

    // verify binding
    if ($ldapbind) {
        echo "LDAP bind successful...";
    } else {
        echo "LDAP bind failed...";
    }

}

?>

When your application is launched, you need to access the LDAP with the windows login credentials.

`AUTH_USER` request variable is the one which you have to check. 
  This will hold your Windows login username and AUTH_USER will be 
  MYDOMAINNAME\user.name

The username/password I need for this, is that admin credentials, or any user on the system?

You can get the username alone, not the password... when the user logs into his window's machine, we can check his credentials using Environment.username in C# and in PHP we can use AUTH_USER to verify the user logged in is valid.

Plus, do you know where can I find a list of variables (like auth_user) of which information can I get?

http://in3.php.net/manual/en/ref.ldap.php

You can get a lot of information from the above link.

Vinothbabu
The username/password I need for this, is that admin credentials, or any user on the system?Plus, do you know where can I find a list of variables (like auth_user) of which information can I get?
modz0r
Yeah I didn't mean getting the user's password.. I meant to the user/password I need to enter into the $ldaprdn/$ldappass variables.I will check what you wrote, and the the link, tomorrow.. but it seems like that's what I needed (once I'll verify it i'll accept the answer). Thanks!
modz0r
Ok, so it seems like it's pretty much what we did use, and it's not exactly what we need.. but that's the best we can get of it.What I wanted to do, is get this information without asking the user for he's user/password. Well, that's the close as I can get. Thanks for the help!
modz0r