Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#btnLogin').click(function(){
- if (frmLogin.valid()){
- var user = $('#frmLoginUser').val();
- var pass = $('#frmLoginPass').val();
- var sinLDAP = false;
- var pos1 = user.indexOf('DOMINIO\');
- if(pos1==-1){
- user = 'DOMINIO'+'\'+user;
- }
- console.log(user);
- console.log(pass);
- console.log(sinLDAP);
- $.ajax({
- type:"POST",
- data: {'user':user,'pass':pass, 'sinLDAP':sinLDAP},
- url:"{{ path('check_ldap') }}"
- }).done(function(respuesta){
- console.log(respuesta.result);
- console.log(respuesta.mensaje);
- if (respuesta.result==9){
- notificaciones('info','Sin validar LDAP','')
- }
- if (respuesta.mensaje==1 && respuesta.result==-1)
- notificaciones(respuesta.tipo_msg,respuesta.msg,respuesta.title_msg);
- else{
- notificaciones('success','Se logueo correctamente','')
- }
- });
- }
- });
- public function checkLdapAction()
- {
- $user = $request->request->get('user');
- $pass = $request->request->get('pass');
- $ldap = $request->request->get('sinLDAP');
- if ($ldap){
- //********************************************************
- return new JsonResponse(array('mensaje' => '0','result' => '1'));
- //********************************************************
- }
- $ldapServer = 'nombre.server.ldap';
- $ldapServerIP = 'XXX.XXX.XXX.XXX';
- $ldapServerPort = 'XXXX';
- $hostip = @gethostbyname($ldapServer);
- $errorConx = ($hostip == $ldapServer || $hostip!=$ldapServerIP);
- if ($errorConx){
- //********************************************************
- return new JsonResponse(array('mensaje' => '1',
- 'result' => '-1',
- 'tipo_msg' => 'error',
- 'title_msg' => 'Error en Conexión',
- 'msg' => 'Error de conexión con el servidor LDAP "'.$ldapServer.'"'));
- //********************************************************
- }
- $ldap_conn = ldap_connect($ldapServer,$ldapServerPort);
- $binding = @ldap_bind($ldap_conn, $user, $pass);
- if ($binding){
- ldap_close($ldap_conn);
- //********************************************************
- return new JsonResponse(array('mensaje' => '0','result' => '1'));
- //********************************************************
- }
- else{
- ldap_close($ldap_conn);
- //********************************************************
- return new JsonResponse(array('mensaje' => '1',
- 'result' => '-1',
- 'tipo_msg' => 'warning',
- 'title_msg' => 'Datos Incorrectos',
- 'msg' => 'Usuario o contraseña incorrecto'));
- //********************************************************
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement