From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 21:45:27 +0200 Subject: more scrutinizer issue improvements --- lib/plugins/authad/auth.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index a3119dda6..65f0b1647 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -203,6 +203,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } //general user info + $info = array(); $info['name'] = $result[0]['displayname'][0]; $info['mail'] = $result[0]['mail'][0]; $info['uid'] = $result[0]['samaccountname'][0]; -- cgit v1.2.3 From 253d4b48ec708eb42033862dc15c8576f44a48ed Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 15:32:05 +0200 Subject: more PHPDocs, unused var, small bit code reformatting --- lib/plugins/authad/auth.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 65f0b1647..88b56046c 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -329,6 +329,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * Bulk retrieval of user data * * @author Dominik Eckelmann + * * @param int $start index of first user to be returned * @param int $limit max number of users to be returned * @param array $filter array of field/pattern pairs, null for no filter @@ -447,7 +448,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { /** * Get the domain part from a user * - * @param $user + * @param string $user * @return string */ public function _userDomain($user) { @@ -458,7 +459,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { /** * Get the user part from a user * - * @param $user + * @param string $user * @return string */ public function _userName($user) { @@ -544,6 +545,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * The patterns are set up with $this->_constructPattern() * * @author Chris Smith + * * @param string $user * @param array $info * @return bool @@ -565,6 +567,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * Create a pattern for $this->_filter() * * @author Chris Smith + * * @param array $filter */ protected function _constructPattern($filter) { -- cgit v1.2.3 From 25f80763dd71190679289de2b8d29f28021aedb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Wed, 11 Mar 2015 19:49:14 +0100 Subject: Get total number of users in ad, needed for paging --- lib/plugins/authad/auth.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 88b56046c..a0a1143db 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -116,6 +116,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { // other can do's are changed in $this->_loadServerConfig() base on domain setup $this->cando['modName'] = true; $this->cando['modMail'] = true; + $this->cando['getUserCount'] = true; } /** @@ -325,6 +326,26 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { return false; } + /** + * @param array $filter + * @return int + */ + public function getUserCount($filter = array()) { + + $adldap = $this->_adldap(null); + if(!$adldap) { + dbglog("authad/auth.php: _adldap not set."); + return -1; + } + + $result = $adldap->user()->all(); + if (!$result) { + dbglog("authad/auth.php: getting all users failed."); + return -1; + } + return count($result); + } + /** * Bulk retrieval of user data * -- cgit v1.2.3 From 67a31a83dd6c8a3ff9e87da0c2070a2783aec44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 12 Mar 2015 13:09:08 +0100 Subject: Create and use ad search for user, name and email --- lib/plugins/authad/auth.php | 68 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 11 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index a0a1143db..f1f34245e 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -326,19 +326,63 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { return false; } + protected function _constructSearchString($filter){ + if (!$filter){ + return '*'; + } + $result = '*'; + if (isset($filter['name'])) { + $result .= ')(displayname=*' . $filter['name'] . '*'; + unset($filter['name']); + } + if (isset($filter['user'])) { + $result .= ')(samAccountName=*' . $filter['user'] . '*'; + unset($filter['user']); + } + + if (isset($filter['mail'])) { + $result .= ')(mail=*' . $filter['mail'] . '*'; + unset($filter['mail']); + } + dbglog($result); + return $result; + } + /** * @param array $filter * @return int */ public function getUserCount($filter = array()) { + if ($filter == array()) { + $adldap = $this->_adldap(null); + if(!$adldap) { + dbglog("authad/auth.php getUserCount(): _adldap not set."); + return -1; + } + $result = $adldap->user()->all(); + $start = 0; + } else {/* + dbglog('_startcache: ' . $this->_startcache); + $usermanager = plugin_load("admin", "usermanager", false); + if ($this->_startcache < $usermanager->getStart()) { + $start = $usermanager->getStart(); + $this->_startcache = $start; + } else { + $start = $this->_startcache; + } + $pagesize = $usermanager->getPagesize(); + $result = $this->retrieveUsers($start, 3*$pagesize,$filter,false);*/ + $adldap = $this->_adldap(null); + if(!$adldap) { + dbglog("authad/auth.php getUserCount(): _adldap not set."); + return -1; + } + dbglog($filter); + $searchString = $this->_constructSearchString($filter); + $result = $adldap->user()->all(false, $searchString); - $adldap = $this->_adldap(null); - if(!$adldap) { - dbglog("authad/auth.php: _adldap not set."); - return -1; } - $result = $adldap->user()->all(); if (!$result) { dbglog("authad/auth.php: getting all users failed."); return -1; @@ -351,18 +395,20 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * * @author Dominik Eckelmann * - * @param int $start index of first user to be returned - * @param int $limit max number of users to be returned - * @param array $filter array of field/pattern pairs, null for no filter - * @return array userinfo (refer getUserData for internal userinfo details) + * @param int $start index of first user to be returned + * @param int $limit max number of users to be returned + * @param array $filter array of field/pattern pairs, null for no filter + * @param bool $setStart + * @return array userinfo (refer getUserData for internal userinfo details) */ - public function retrieveUsers($start = 0, $limit = 0, $filter = array()) { + public function retrieveUsers($start = 0, $limit = 0, $filter = array(), $setStart = true) { + dbglog("start: " . $start . "; limit: " . $limit); $adldap = $this->_adldap(null); if(!$adldap) return false; if(!$this->users) { //get info for given user - $result = $adldap->user()->all(); + $result = $adldap->user()->all(false, $this->_constructSearchString($filter)); if (!$result) return array(); $this->users = array_fill_keys($result, false); } -- cgit v1.2.3 From c52f6cd2bf68bccfbc665f376f68c93861a99837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 12 Mar 2015 14:50:23 +0100 Subject: When filtering for group implement prefetching --- lib/plugins/authad/auth.php | 82 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 8 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index f1f34245e..2710d6a17 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -67,6 +67,10 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { */ protected $_pattern = array(); + protected $_actualstart = 0; + + protected $_grpsusers = array(); + /** * Constructor */ @@ -380,6 +384,16 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { dbglog($filter); $searchString = $this->_constructSearchString($filter); $result = $adldap->user()->all(false, $searchString); + if (isset($filter['grps'])) { + $this->users = array_fill_keys($result, false); + $usermanager = plugin_load("admin", "usermanager", false); + if (!isset($this->_grpsusers[$this->_filterToString($filter)])){ + $this->_fillGroupUserArray($filter,$usermanager->getStart() + 3*$usermanager->getPagesize()); + } elseif (count($this->_grpsusers[$this->_filterToString($filter)]) < getStart() + 3*$usermanager->getPagesize()) { + $this->_fillGroupUserArray($filter,$usermanager->getStart() + 3*$usermanager->getPagesize() - count($this->_grpsusers[$this->_filterToString($filter)])); + } + $result = $this->_grpsusers[$this->_filterToString($filter)]; + } } @@ -390,6 +404,44 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { return count($result); } + protected function _filterToString ($filter) { + $result = ''; + if (isset($filter['user'])) { + $result .= 'user-' . $filter['user']; + } + if (isset($filter['name'])) { + $result .= 'name-' . $filter['name']; + } + if (isset($filter['mail'])) { + $result .= 'mail-' . $filter['mail']; + } + if (isset($filter['grps'])) { + $result .= 'grps-' . $filter['grps']; + } + return $result; + } + + protected function _fillGroupUserArray($filter, $numberOfAdds){ + $this->_grpsusers[$this->_filterToString($filter)]; + $i = 0; + $count = 0; + $this->_constructPattern($filter); + foreach ($this->users as $user => &$info) { + if($i++ < $this->_actualstart) { + continue; + } + if($info === false) { + $info = $this->getUserData($user); + } + if($this->_filter($user, $info)) { + $this->_grpsusers[$this->_filterToString($filter)][$user] = $info; + if(($numberOfAdds > 0) && (++$count >= $numberOfAdds)) break; + } + } + $this->_actualstart = $i; + return $count; + } + /** * Bulk retrieval of user data * @@ -398,10 +450,9 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * @param int $start index of first user to be returned * @param int $limit max number of users to be returned * @param array $filter array of field/pattern pairs, null for no filter - * @param bool $setStart * @return array userinfo (refer getUserData for internal userinfo details) */ - public function retrieveUsers($start = 0, $limit = 0, $filter = array(), $setStart = true) { + public function retrieveUsers($start = 0, $limit = 0, $filter = array()) { dbglog("start: " . $start . "; limit: " . $limit); $adldap = $this->_adldap(null); if(!$adldap) return false; @@ -418,17 +469,32 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { $this->_constructPattern($filter); $result = array(); - foreach($this->users as $user => &$info) { - if($i++ < $start) { - continue; + if (!isset($filter['grps'])) { + foreach($this->users as $user => &$info) { + if($i++ < $start) { + continue; + } + if($info === false) { + $info = $this->getUserData($user); + } + if($this->_filter($user, $info)) { + $result[$user] = $info; + if(($limit > 0) && (++$count >= $limit)) break; + } } - if($info === false) { - $info = $this->getUserData($user); + } else { + if (!isset($this->_grpsusers[$this->_filterToString($filter)]) || count($this->_grpsusers[$this->_filterToString($filter)]) < ($start+$limit)) { + $this->_fillGroupUserArray($filter,$start+$limit - count($this->_grpsusers[$this->_filterToString($filter)]) +1); } - if($this->_filter($user, $info)) { + foreach($this->_grpsusers[$this->_filterToString($filter)] as $user => &$info) { + dbglog($this->_grpsusers[$this->_filterToString($filter)]); + if($i++ < $start) { + continue; + } $result[$user] = $info; if(($limit > 0) && (++$count >= $limit)) break; } + } return $result; } -- cgit v1.2.3 From 462e9e37f38d6de9ec19ad1476b64bac3b851fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 12 Mar 2015 15:06:26 +0100 Subject: Disable the ``last`` button when filtering groups Since we cannot effectively filter for groups and have to work with incremental prefetching, the ``last`` button is mostly broken/buggy. Hence it is disabled in this usecase. --- lib/plugins/authad/auth.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 2710d6a17..4022cd68f 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -387,12 +387,16 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { if (isset($filter['grps'])) { $this->users = array_fill_keys($result, false); $usermanager = plugin_load("admin", "usermanager", false); + $usermanager->setLastdisabled(true); if (!isset($this->_grpsusers[$this->_filterToString($filter)])){ $this->_fillGroupUserArray($filter,$usermanager->getStart() + 3*$usermanager->getPagesize()); } elseif (count($this->_grpsusers[$this->_filterToString($filter)]) < getStart() + 3*$usermanager->getPagesize()) { $this->_fillGroupUserArray($filter,$usermanager->getStart() + 3*$usermanager->getPagesize() - count($this->_grpsusers[$this->_filterToString($filter)])); } $result = $this->_grpsusers[$this->_filterToString($filter)]; + } else { + $usermanager = plugin_load("admin", "usermanager", false); + $usermanager->setLastdisabled(false); } } @@ -470,6 +474,8 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { $result = array(); if (!isset($filter['grps'])) { + $usermanager = plugin_load("admin", "usermanager", false); + $usermanager->setLastdisabled(false); foreach($this->users as $user => &$info) { if($i++ < $start) { continue; @@ -483,6 +489,8 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } } } else { + $usermanager = plugin_load("admin", "usermanager", false); + $usermanager->setLastdisabled(true); if (!isset($this->_grpsusers[$this->_filterToString($filter)]) || count($this->_grpsusers[$this->_filterToString($filter)]) < ($start+$limit)) { $this->_fillGroupUserArray($filter,$start+$limit - count($this->_grpsusers[$this->_filterToString($filter)]) +1); } -- cgit v1.2.3 From 6fcf992c3420a8904add8169cfd672407a7c38d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 12 Mar 2015 16:00:26 +0100 Subject: Clean up code, add phpdoc comments, some refactoring, etc. --- lib/plugins/authad/auth.php | 62 ++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 4022cd68f..bcf01ff21 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -330,6 +330,10 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { return false; } + /** + * @param array $filter + * @return string + */ protected function _constructSearchString($filter){ if (!$filter){ return '*'; @@ -348,7 +352,6 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { $result .= ')(mail=*' . $filter['mail'] . '*'; unset($filter['mail']); } - dbglog($result); return $result; } @@ -357,31 +360,14 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * @return int */ public function getUserCount($filter = array()) { + $adldap = $this->_adldap(null); + if(!$adldap) { + dbglog("authad/auth.php getUserCount(): _adldap not set."); + return -1; + } if ($filter == array()) { - $adldap = $this->_adldap(null); - if(!$adldap) { - dbglog("authad/auth.php getUserCount(): _adldap not set."); - return -1; - } $result = $adldap->user()->all(); - $start = 0; - } else {/* - dbglog('_startcache: ' . $this->_startcache); - $usermanager = plugin_load("admin", "usermanager", false); - if ($this->_startcache < $usermanager->getStart()) { - $start = $usermanager->getStart(); - $this->_startcache = $start; - } else { - $start = $this->_startcache; - } - $pagesize = $usermanager->getPagesize(); - $result = $this->retrieveUsers($start, 3*$pagesize,$filter,false);*/ - $adldap = $this->_adldap(null); - if(!$adldap) { - dbglog("authad/auth.php getUserCount(): _adldap not set."); - return -1; - } - dbglog($filter); + } else { $searchString = $this->_constructSearchString($filter); $result = $adldap->user()->all(false, $searchString); if (isset($filter['grps'])) { @@ -390,7 +376,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { $usermanager->setLastdisabled(true); if (!isset($this->_grpsusers[$this->_filterToString($filter)])){ $this->_fillGroupUserArray($filter,$usermanager->getStart() + 3*$usermanager->getPagesize()); - } elseif (count($this->_grpsusers[$this->_filterToString($filter)]) < getStart() + 3*$usermanager->getPagesize()) { + } elseif (count($this->_grpsusers[$this->_filterToString($filter)]) < $usermanager->getStart() + 3*$usermanager->getPagesize()) { $this->_fillGroupUserArray($filter,$usermanager->getStart() + 3*$usermanager->getPagesize() - count($this->_grpsusers[$this->_filterToString($filter)])); } $result = $this->_grpsusers[$this->_filterToString($filter)]; @@ -402,12 +388,18 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } if (!$result) { - dbglog("authad/auth.php: getting all users failed."); - return -1; + return 0; } return count($result); } + /** + * + * create a unique string for each filter used with a group + * + * @param array $filter + * @return string + */ protected function _filterToString ($filter) { $result = ''; if (isset($filter['user'])) { @@ -425,6 +417,11 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { return $result; } + /** + * @param array $filter + * @param int $numberOfAdds additional number of users requested + * @return int number of Users actually add to Array + */ protected function _fillGroupUserArray($filter, $numberOfAdds){ $this->_grpsusers[$this->_filterToString($filter)]; $i = 0; @@ -457,7 +454,6 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { * @return array userinfo (refer getUserData for internal userinfo details) */ public function retrieveUsers($start = 0, $limit = 0, $filter = array()) { - dbglog("start: " . $start . "; limit: " . $limit); $adldap = $this->_adldap(null); if(!$adldap) return false; @@ -470,12 +466,12 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { $i = 0; $count = 0; - $this->_constructPattern($filter); $result = array(); if (!isset($filter['grps'])) { $usermanager = plugin_load("admin", "usermanager", false); $usermanager->setLastdisabled(false); + $this->_constructPattern($filter); foreach($this->users as $user => &$info) { if($i++ < $start) { continue; @@ -483,10 +479,8 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { if($info === false) { $info = $this->getUserData($user); } - if($this->_filter($user, $info)) { - $result[$user] = $info; - if(($limit > 0) && (++$count >= $limit)) break; - } + $result[$user] = $info; + if(($limit > 0) && (++$count >= $limit)) break; } } else { $usermanager = plugin_load("admin", "usermanager", false); @@ -494,8 +488,8 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { if (!isset($this->_grpsusers[$this->_filterToString($filter)]) || count($this->_grpsusers[$this->_filterToString($filter)]) < ($start+$limit)) { $this->_fillGroupUserArray($filter,$start+$limit - count($this->_grpsusers[$this->_filterToString($filter)]) +1); } + if (!$this->_grpsusers[$this->_filterToString($filter)]) return false; foreach($this->_grpsusers[$this->_filterToString($filter)] as $user => &$info) { - dbglog($this->_grpsusers[$this->_filterToString($filter)]); if($i++ < $start) { continue; } -- cgit v1.2.3 From 7910cbbbce7fd803f3ee4f458d5426eac51bfd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 12 Mar 2015 16:34:45 +0100 Subject: Explain functions in docstrings --- lib/plugins/authad/auth.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index bcf01ff21..321a60f24 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -331,6 +331,8 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } /** + * Create a Search-String useable by adLDAPUsers::all($includeDescription = false, $search = "*", $sorted = true) + * * @param array $filter * @return string */ @@ -343,6 +345,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { $result .= ')(displayname=*' . $filter['name'] . '*'; unset($filter['name']); } + if (isset($filter['user'])) { $result .= ')(samAccountName=*' . $filter['user'] . '*'; unset($filter['user']); @@ -356,8 +359,10 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } /** - * @param array $filter - * @return int + * Return a count of the number of user which meet $filter criteria + * + * @param array $filter $filter array of field/pattern pairs, empty array for no filter + * @return int number of users */ public function getUserCount($filter = array()) { $adldap = $this->_adldap(null); @@ -418,6 +423,10 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { } /** + * Create an array of $numberOfAdds users passing a certain $filter, including belonging + * to a certain group and save them to a object-wide array. If the array + * already exists try to add $numberOfAdds further users to it. + * * @param array $filter * @param int $numberOfAdds additional number of users requested * @return int number of Users actually add to Array -- cgit v1.2.3 From 07aec0297354ce1a2bb273def8173ff0a524f852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 12 Mar 2015 16:57:13 +0100 Subject: Escape user strings given to adLDAP --- lib/plugins/authad/auth.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 321a60f24..400a5efee 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -3,6 +3,7 @@ if(!defined('DOKU_INC')) die(); require_once(DOKU_PLUGIN.'authad/adLDAP/adLDAP.php'); +require_once(DOKU_PLUGIN.'authad/adLDAP/classes/adLDAPUtils.php'); /** * Active Directory authentication backend for DokuWiki @@ -340,19 +341,20 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { if (!$filter){ return '*'; } + $adldapUtils = new adLDAPUtils($this->_adldap(null)); $result = '*'; if (isset($filter['name'])) { - $result .= ')(displayname=*' . $filter['name'] . '*'; + $result .= ')(displayname=*' . $adldapUtils->ldapSlashes($filter['name']) . '*'; unset($filter['name']); } if (isset($filter['user'])) { - $result .= ')(samAccountName=*' . $filter['user'] . '*'; + $result .= ')(samAccountName=*' . $adldapUtils->ldapSlashes($filter['user']) . '*'; unset($filter['user']); } if (isset($filter['mail'])) { - $result .= ')(mail=*' . $filter['mail'] . '*'; + $result .= ')(mail=*' . $adldapUtils->ldapSlashes($filter['mail']) . '*'; unset($filter['mail']); } return $result; -- cgit v1.2.3 From 5b795a651d514c6889ad05abc4e58de67c7af92e Mon Sep 17 00:00:00 2001 From: Patrick Brown Date: Tue, 31 Mar 2015 21:53:01 -0400 Subject: Move language string to authad plugin --- lib/plugins/authad/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 400a5efee..40c56ef09 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -258,7 +258,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { ($info['expiresin'] <= $this->conf['expirywarn']) && !$this->msgshown ) { - $msg = sprintf($lang['authpwdexpire'], $info['expiresin']); + $msg = sprintf($this->getLang('authpwdexpire'), $info['expiresin']); if($this->canDo('modPass')) { $url = wl($ID, array('do'=> 'profile')); $msg .= ' '.$lang['btn_profile'].''; -- cgit v1.2.3 From 8f03c311f28eaffe92893ec1a4d0b78581926e13 Mon Sep 17 00:00:00 2001 From: Patrick Brown Date: Wed, 6 May 2015 15:31:08 -0400 Subject: Error reporting for database auth plugins --- lib/plugins/authad/auth.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/plugins/authad/auth.php') diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index 40c56ef09..60c68efc4 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -522,7 +522,10 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { public function modifyUser($user, $changes) { $return = true; $adldap = $this->_adldap($this->_userDomain($user)); - if(!$adldap) return false; + if(!$adldap) { + msg($this->getLang('connectfail'), -1); + return false; + } // password changing if(isset($changes['pass'])) { @@ -532,7 +535,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { if ($this->conf['debug']) msg('AD Auth: '.$e->getMessage(), -1); $return = false; } - if(!$return) msg('AD Auth: failed to change the password. Maybe the password policy was not met?', -1); + if(!$return) msg($this->getLang('passchangefail'), -1); } // changing user data @@ -554,6 +557,7 @@ class auth_plugin_authad extends DokuWiki_Auth_Plugin { if ($this->conf['debug']) msg('AD Auth: '.$e->getMessage(), -1); $return = false; } + if(!$return) msg($this->getLang('userchangefail'), -1); } return $return; -- cgit v1.2.3