summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-11-03 12:36:18 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-11-03 12:36:18 (GMT)
commitbe7ef6f18d07aa3f71be0184c8845c646fa09a18 (patch)
tree42ae1974d090e6d3f1bd6f0baa5c1c65e53d9b01
parent3e93d76e5163daf454c06d335960b7350b035aba (diff)
downloadkolab-wap-be7ef6f18d07aa3f71be0184c8845c646fa09a18.tar.gz
Fix _find_domain() optimization from commit 7bc79c68dd
-rw-r--r--lib/Auth/LDAP.php26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index cf5c062..a175fc8 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -1488,15 +1488,23 @@ class LDAP extends Net_LDAP3 {
// use memcache
$domain_dn = $this->get_cache_data($ckey);
- // connect and bind only if needed
- if (empty($this->_current_bind_dn)
- && (!$domain_dn || empty($_SESSION['user']) || empty($_SESSION['user']->user_bind_dn))
- ) {
- $bind_dn = $this->conf->get('service_bind_dn');
- $bind_pw = $this->conf->get('service_bind_pw');
-
- if (!$this->bind($bind_dn, $bind_pw)) {
- return false;
+ // connect and bind only if needed...
+ if (empty($this->_current_bind_dn)) {
+ $bind_dn = $_SESSION['user'] ? $_SESSION['user']->user_bind_dn : null;
+
+ // ...and it is needed if we ned to call _read() or _search() below
+ if (!$domain_dn || !$bind_dn) {
+ if ($bind_dn) {
+ $bind_pw = $_SESSION['user']->user_bind_pw;
+ }
+ else {
+ $bind_dn = $this->conf->get('service_bind_dn');
+ $bind_pw = $this->conf->get('service_bind_pw');
+ }
+
+ if (!$this->bind($bind_dn, $bind_pw)) {
+ return false;
+ }
}
}