source: admin/WebConsole/validacion/html/validacion_ldap.php @ 8c7b374

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since 8c7b374 was 043e67d, checked in by pablombg <noreply@…>, 7 years ago

#814: Sustituir las etiquetas cortas de php por el formato largo

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5502 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 1.6 KB
Line 
1<?php
2
3function connect_to_ldap(){     
4        $server = "IP_SERVIDOR";
5        $port = '389';
6        $user = "USUARIO";
7        $pass = "PASSWORD";
8               
9        $result = null;
10        $ds=ldap_connect($server,$port);
11        if ($ds){
12                if ($r=@ldap_bind($ds,$user,$pass))
13                        $result = $ds;
14        }
15        return $result;
16}
17       
18function validate_user($user,$password){
19        if (($user=='') || ($password=='')){
20                $result['validation'] = -1;
21        }else{
22                if($ds = connect_to_ldap()){
23                        $dc = "dc=uhu, dc=es";
24                        $search = "uid=".$user;
25                        $sr=@ldap_search($ds,$dc,$search);
26                        $info = @ldap_get_entries($ds, $sr);
27
28                        if ($info["count"]==1){                                 
29                                $thedata = $info[0]["dn"];                                     
30                                if ($r=@ldap_bind($ds,$thedata,$password)){
31                                        $result['validation'] = 1;
32                                        // A parte de la validacion, se podrían coger otros datos...
33                                        /*
34                                        $result['name'] = $info[0]["cn"][0];
35                                        $result['dni'] = $info[0]["uhuuserdni"][0];
36                                        $result['email'] =  $info[0]["mail"][0];
37                                        */
38                                }
39                                else{
40                                        $result['validation'] = -1;
41                                }
42                        }
43                        else{
44                                $result['validation'] = -1;
45                        }                               
46                }
47                ldap_close($ds);
48        }
49        return $result;
50}
51
52/**
53 * Sincroniza una base de datos externa con la de opengnsys.
54 * No es necesaria su implementacion, puede dejarse en blanco
55 */
56function synchronize($validation){
57
58}
59
60
61/**
62 * Funcion de validacion para el cliente opengnsys.
63 * Recibe como parametros la variable $_POST proveniente de la pagina de login
64 * debe devolver true o false
65 */
66function validate($VARS){
67        $result=false;
68        $validationInfo = validate_user($VARS["login"], $VARS["password"]);
69        if($validationInfo["validation"] == 1){
70                $result = true;
71        }
72        return $result;
73}
74
75?>
Note: See TracBrowser for help on using the repository browser.