Reputation: 93
HI Am trying to connect and unbind the server and port ldap connection using php.
Here is my code:
$hostname = 'ldaps://www.google.com';
$port = 636;
echo "ldap check";
$lp = ldap_connect($hostname,$port);
echo "servername";
echo $_SERVER['PHP_AUTH_USER'];
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if ($bind = @ldap_bind($lp, $username.$hostname, $password)){
echo "Hello";
ldap_unbind($lp,$username,$password);
}
Failure:
But am not connecting with the ldap connection.PLease help me to fix the code.
Upvotes: 0
Views: 171
Reputation: 3861
When I read your code right, there are two issues:
The port you are giving will never be used in the ldap_connect
. The docs clearly state that using the port as second argument to ldap_connect
is deprecated and will only be used when you pass a servername or IP. But you are passing a URI, so that needs to include the port as well.
You are trying to bind as $username . $hostname
. So you are tying to conntect 'someuser' as someuserldaps://www.google.com
- I doubt that that will ever work. You probably want something like [email protected]
...
Upvotes: 1