La situación q tengo es la siguiente….
Tengo un servidor LDAP para autentificar al usuario, el problema se presenta cuando trato de autenticar en un directorio LDAP.
El código que estoy haciendo como prueba es:
NOTA: el password esta cifrado con SSHA.
Código PHP:
<?
$host = "URL_SERVIDOR_LDAP";
$puerto = 389;
$conex=ldap_connect($host,$puerto) or die ("No ha sido posible conectarse al servidor");
$admin="uid=login_usuario, ou=people, dc=institucion, dc=gob, dc=ve";
$passwd='XXXXX';
// Generate SSHA hash
mt_srand((double)microtime()*1000000);
$salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($password . $salt)) . $salt);
if (ldap_set_option($conex, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "<br>Using LDAPv3";
} else {
echo "<br>Failed to set protocol version to 3";
}
if ($conex) {
// bind with appropriate dn to give update access
$r=ldap_bind($conex, $admin, $hash);
if ($r)
{echo "<br>Congratulations! $username is authenticated.";}
else
{echo "<br>Nice try, kid. Better luck next time!";}
ldap_close($conex);
} else {
echo "Unable to connect to LDAP server";
}
?>
Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Invalid credentials in C:\Archivos de programa\xampp\htdocs\prueba_ldap.php on line 24
Estuve averiguando por el Internet y allí leí que se debe a un error en el usuario o password, mi pregunta es q si se coloca así el usuario??... el usuario lo tome cuando entro al servidor ldap a través de la Web.
Muchas gracias
![sonriente](http://static.forosdelweb.com/fdwtheme/images/smilies/smile.png)