summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-10-30 18:13:27 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-10-30 18:13:27 (GMT)
commit9889e6561f7cabfdb7ddb69848b55ac52151e21f (patch)
tree97269feeafbb01a21cd32637a140abb4bdb96770
parentc864d8b95d776276cbddddb71a6a9d5130d83ddc (diff)
downloadkolab-freebusy-9889e6561f7cabfdb7ddb69848b55ac52151e21f.tar.gz
Quote filter attribute value; add fallback domain name for LDAP queries
-rw-r--r--config/config.ini.sample2
-rw-r--r--lib/Kolab/FreeBusy/DirectoryLDAP.php3
2 files changed, 4 insertions, 1 deletions
diff --git a/config/config.ini.sample b/config/config.ini.sample
index 77abec5..b97c011 100644
--- a/config/config.ini.sample
+++ b/config/config.ini.sample
@@ -35,6 +35,7 @@ base_dn = "ou=People,dc=example,dc=org"
filter = "(&(objectClass=kolabInetOrgPerson)(|(mail=%s)(alias=%s))"
attributes[] = mail
lc_attributes[] = mail
+primary_domain = "example.org"
; %s is replaced by the user's result_attribute found
fbsource = imaps://%s:CyrusAdminPassword@imap.example.org/?proxy_auth=cyrus-admin
@@ -53,6 +54,7 @@ bind_pw = "SomePassword"
base_dn = "ou=Resources,dc=example,dc=org"
filter = "(&(objectClass=kolabsharedfolder)(kolabfoldertype=event)(mail=%s))"
attributes = mail, kolabtargetfolder
+primary_domain = "example.org"
; Use the Free/Busy daemon that separates the abuse of credentials
;fbsource = "fbdaemon://localhost:<port>?folder=%kolabtargetfolder"
diff --git a/lib/Kolab/FreeBusy/DirectoryLDAP.php b/lib/Kolab/FreeBusy/DirectoryLDAP.php
index 0a4ecff..c155d98 100644
--- a/lib/Kolab/FreeBusy/DirectoryLDAP.php
+++ b/lib/Kolab/FreeBusy/DirectoryLDAP.php
@@ -101,9 +101,10 @@ class DirectoryLDAP extends Directory
if ($this->ready) {
// search with configured base_dn and filter
list($u, $d) = explode('@', $user);
+ if (empty($d)) $d = $this->config['primary_domain'];
$replaces = array('%dc' => 'dc=' . str_replace('.', ',dc=', $d), '%u' => $u);
$base_dn = strtr($this->config['base_dn'], $replaces);
- $filter = preg_replace('/%s/i', $user, strtr($this->config['filter'], $replaces));
+ $filter = str_replace('%s', Net_LDAP3::quote_string($user), strtr($this->config['filter'], $replaces));
$ldapresult = $this->ldap->search($base_dn, $filter, 'sub', Config::convert($this->config['attributes'], Config::ARR));
// got a valid result