PHP - Php jQuery Ldap

 
Vista:
sin imagen de perfil

Php jQuery Ldap

Publicado por Santiago (1 intervención) el 07/05/2018 02:17:41
Estimados,

Estoy haciendo una autenticacion, via LDAP usando como servidor de prueba ldap.forumsys.com.

Aqui el PHP que realiza la Query al servidor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
 
sleep(1);
 
$ldap_dn = "uid=".$_POST["usuariolg"].",dc=example,dc=com";
$ldap_password = $_POST["passlg"];
 
$ldap_con = ldap_connect("ldap.forumsys.com");
ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
 
 
 
 
 
if (@ldap_bind($ldap_con,$ldap_dn,$ldap_password)) {
 
    echo "Authenticated";
 
	//var_dump($_POST['usuariolg']);
	//var_dump($_POST['passlg']);
 
	echo json_encode(array('error' => false));
 
 
} else {
    echo "Invalid Credential";
    echo json_encode(array('error' => true));
}
 
?>

Aqui el JS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
jQuery(document).on('submit','#formlg', function (event) {
 
    event.preventDefault();
 
    jQuery.ajax({
        url: 'login.php',
        type: 'POST',
        dataType: 'json',
        data: $(this).serialize(),
        beforeSend: function(){
            $('.botonlg').val('Validando...');
        }
    })
    .done(function(respuesta){
        console.log(respuesta);
        if(!respuesta.error){
            console.log("Ingreso a la Redireccion");
            location.href='index.php';
 
        }else{
            $('.error').slideDown('slow');
            setTimeout(function(){
                $('.error').slideUp('slow');
            },2000);
            $('.botonlg').val('Iniciar Sesion');
        }
 
    })
    .fail(function(resp){
        console.log(resp.responseText);
    })
    .always(function(){
        console.log("complete");
    });
 
});

Aqui la consola. No entiendo por que no ingresa a .done para hacer la redireccion.



Captura-de-pantalla-de-2018-05-06-21-16-43

Saludos y muchas gracias!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder