From 48bd73305937722d43671a18e6e8b89626cf1264 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 2 Nov 2009 15:13:33 +0100 Subject: ad auth: do not connect to AD server in constructor FS#1791 Ignore-this: 5b5b6e67b2800c0ecde8b65de303c4df darcs-hash:20091102141333-6e07b-70ea837064d771c088b4e0000021778b5b8178c5.gz --- inc/auth/ad.class.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'inc/auth') diff --git a/inc/auth/ad.class.php b/inc/auth/ad.class.php index 05c4c1f8e..f1440969a 100644 --- a/inc/auth/ad.class.php +++ b/inc/auth/ad.class.php @@ -81,13 +81,6 @@ class auth_ad extends auth_basic { $opts['domain_controllers'] = array_map('trim',$opts['domain_controllers']); $opts['domain_controllers'] = array_filter($opts['domain_controllers']); - // connect - try { - $this->adldap = new adLDAP($opts); - } catch (adLDAPException $e) { - $this->success = false; - } - // we currently just handle authentication, so no capabilities are set } @@ -106,6 +99,7 @@ class auth_ad extends auth_basic { $_SERVER['REMOTE_USER'] == $user && $this->cnf['sso']) return true; + if(!$this->_init()) return false; return $this->adldap->authenticate($user, $pass); } @@ -129,6 +123,8 @@ class auth_ad extends auth_basic { */ function getUserData($user){ global $conf; + if(!$this->_init()) return false; + //get info for given user $result = $this->adldap->user_info($user); @@ -171,6 +167,23 @@ class auth_ad extends auth_basic { return $sName; } + + /** + * Initialize the AdLDAP library and connect to the server + */ + function _init(){ + if(!is_null($this->adldap)) return true; + + // connect + try { + $this->adldap = new adLDAP($opts); + return true; + } catch (adLDAPException $e) { + $this->success = false; + $this->adldap = null; + } + return false; + } } //Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3