From 0b0dd657a7153e14d5e959f161c93b9cc882c050 Mon Sep 17 00:00:00 2001 From: Andrea Cimbalo Date: Sat, 4 May 2013 15:38:19 +0000 Subject: [PATCH] aggiunta segnalazione errore connessione ldap --- lilikuser.php | 15 ++++++++++++++- user.php | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lilikuser.php b/lilikuser.php index 33342b9..89f3d7f 100644 --- a/lilikuser.php +++ b/lilikuser.php @@ -12,7 +12,12 @@ class LdapAdapter{ function __construct($host, $port, $user, $pass){ $this->conn = ldap_connect($host,$port); ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3); - ldap_bind($this->conn, $user, $pass); + $this->bind_status = ldap_bind($this->conn, $user, $pass); + + } + + function get_bind_status(){ + return $this->bind_status; } function bind($host, $port, $user, $pass){ @@ -245,6 +250,10 @@ abstract class pippo{ $this->la=new LdapAdapter($HOST, $PORT, $LOGIN_DN, $LOGIN_PASS); } + function get_bind_status(){ + return $this->la->get_bind_status(); + } + function get_attr($attr){ foreach($this->adapters as $adapter){ $result=$adapter->get_attr($this->la, $this->id, $attr); @@ -358,6 +367,10 @@ class LilikUser extends pippo{ return $this->status('admin'); } + function is_binded(){ + + } + function enable($service){ if (array_key_exists($service, $this->_flag)){ return $this->set_attr($this->_flag[$service], 'TRUE'); diff --git a/user.php b/user.php index 32a4091..0f37cb0 100644 --- a/user.php +++ b/user.php @@ -23,6 +23,12 @@ include 'lilikuser.php'; $u=new LilikUser($_SESSION['username']); +if (!$u->get_bind_status()){ + $response['error']='Errore di connessione a ldap'; + echo json_encode($response); + exit; +} + #bind ldap or exit $loggedin=$u->check_password($_SESSION['password']); $response['loggedin']=$loggedin;