Login with ActiveDirectory

1

I'm trying to connect to AD. But the error is displayed:

  

Warning: ldap_connect (): Could not create session handle: Bad   parameter to an ldap routine in C: \ Program Files   (x86) \ EasyPHP-DevServer-14.1VC9 \ data \ localweb \ my portable   files \ ad \ php on line 8       Could not connect to LDAP server.

Would anyone know the possible causes for this connection failure?

<?php
$ldap_server = "192.168.2.1/nomeservidor";
$dominio = "DOMINIO/";
$user = $dominio."administrador";

echo $user;

$ldap_porta = "389";
$ldap_pass   = "minhasenha";
$ldapcon = ldap_connect($ldap_server, $ldap_porta) or die("Could not connect to LDAP server.");

if ($ldapcon) {
  $bind = ldap_bind($ldapcon, $user, 'minhaSenha');
  if ($bind) {
    echo "LDAP bind successful…";
  }
  else {
    echo "LDAP bind failed…";
  }
}
?>

Thank you in advance.

    
asked by anonymous 21.07.2016 / 19:37

1 answer

0

Try to use your url connection like this: $ ldap_server="ldap: //192.168.2.1/servername";

Or, put the port number after ip:

192.168.2.1:port

Reference: link

    
22.07.2016 / 00:54