@@ -31,9 +31,9 @@ |
||
31 | 31 | OCP\JSON::checkAppEnabled('user_ldap'); |
32 | 32 | OCP\JSON::callCheck(); |
33 | 33 | |
34 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
34 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
35 | 35 | $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig()); |
36 | -if($helper->deleteServerConfiguration($prefix)) { |
|
36 | +if ($helper->deleteServerConfiguration($prefix)) { |
|
37 | 37 | OCP\JSON::success(); |
38 | 38 | } else { |
39 | 39 | $l = \OC::$server->getL10N('user_ldap'); |
@@ -32,16 +32,16 @@ discard block |
||
32 | 32 | |
33 | 33 | $l = \OC::$server->getL10N('user_ldap'); |
34 | 34 | |
35 | -if(!isset($_POST['action'])) { |
|
35 | +if (!isset($_POST['action'])) { |
|
36 | 36 | \OCP\JSON::error(array('message' => $l->t('No action specified'))); |
37 | 37 | } |
38 | -$action = (string)$_POST['action']; |
|
38 | +$action = (string) $_POST['action']; |
|
39 | 39 | |
40 | 40 | |
41 | -if(!isset($_POST['ldap_serverconfig_chooser'])) { |
|
41 | +if (!isset($_POST['ldap_serverconfig_chooser'])) { |
|
42 | 42 | \OCP\JSON::error(array('message' => $l->t('No configuration specified'))); |
43 | 43 | } |
44 | -$prefix = (string)$_POST['ldap_serverconfig_chooser']; |
|
44 | +$prefix = (string) $_POST['ldap_serverconfig_chooser']; |
|
45 | 45 | |
46 | 46 | $ldapWrapper = new \OCA\User_LDAP\LDAP(); |
47 | 47 | $configuration = new \OCA\User_LDAP\Configuration($prefix); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | $wizard = new \OCA\User_LDAP\Wizard($configuration, $ldapWrapper, $access); |
68 | 68 | |
69 | -switch($action) { |
|
69 | +switch ($action) { |
|
70 | 70 | case 'guessPortAndTLS': |
71 | 71 | case 'guessBaseDN': |
72 | 72 | case 'detectEmailAttribute': |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | case 'countInBaseDN': |
86 | 86 | try { |
87 | 87 | $result = $wizard->$action(); |
88 | - if($result !== false) { |
|
88 | + if ($result !== false) { |
|
89 | 89 | OCP\JSON::success($result->getResultArray()); |
90 | 90 | exit; |
91 | 91 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | try { |
102 | 102 | $loginName = $_POST['ldap_test_loginname']; |
103 | 103 | $result = $wizard->$action($loginName); |
104 | - if($result !== false) { |
|
104 | + if ($result !== false) { |
|
105 | 105 | OCP\JSON::success($result->getResultArray()); |
106 | 106 | exit; |
107 | 107 | } |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | case 'save': |
118 | 118 | $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; |
119 | 119 | $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; |
120 | - if($key === false || is_null($val)) { |
|
120 | + if ($key === false || is_null($val)) { |
|
121 | 121 | \OCP\JSON::error(array('message' => $l->t('No data specified'))); |
122 | 122 | exit; |
123 | 123 | } |
124 | 124 | $cfg = array($key => $val); |
125 | 125 | $setParameters = array(); |
126 | 126 | $configuration->setConfiguration($cfg, $setParameters); |
127 | - if(!in_array($key, $setParameters)) { |
|
127 | + if (!in_array($key, $setParameters)) { |
|
128 | 128 | \OCP\JSON::error(array('message' => $l->t($key. |
129 | 129 | ' Could not set configuration %s', $setParameters[0]))); |
130 | 130 | exit; |
@@ -32,12 +32,12 @@ |
||
32 | 32 | sort($serverConnections); |
33 | 33 | $lk = array_pop($serverConnections); |
34 | 34 | $ln = intval(str_replace('s', '', $lk)); |
35 | -$nk = 's'.str_pad($ln+1, 2, '0', STR_PAD_LEFT); |
|
35 | +$nk = 's'.str_pad($ln + 1, 2, '0', STR_PAD_LEFT); |
|
36 | 36 | |
37 | 37 | $resultData = array('configPrefix' => $nk); |
38 | 38 | |
39 | 39 | $newConfig = new \OCA\User_LDAP\Configuration($nk, false); |
40 | -if(isset($_POST['copyConfig'])) { |
|
40 | +if (isset($_POST['copyConfig'])) { |
|
41 | 41 | $originalConfig = new \OCA\User_LDAP\Configuration($_POST['copyConfig']); |
42 | 42 | $newConfig->setConfiguration($originalConfig->getConfiguration()); |
43 | 43 | } else { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @return bool |
54 | 54 | */ |
55 | 55 | public function isColNameValid($col) { |
56 | - switch($col) { |
|
56 | + switch ($col) { |
|
57 | 57 | case 'ldap_dn': |
58 | 58 | case 'owncloud_name': |
59 | 59 | case 'directory_uuid': |
@@ -72,19 +72,19 @@ discard block |
||
72 | 72 | * @return string|false |
73 | 73 | */ |
74 | 74 | protected function getXbyY($fetchCol, $compareCol, $search) { |
75 | - if(!$this->isColNameValid($fetchCol)) { |
|
75 | + if (!$this->isColNameValid($fetchCol)) { |
|
76 | 76 | //this is used internally only, but we don't want to risk |
77 | 77 | //having SQL injection at all. |
78 | 78 | throw new \Exception('Invalid Column Name'); |
79 | 79 | } |
80 | 80 | $query = $this->dbc->prepare(' |
81 | - SELECT `' . $fetchCol . '` |
|
82 | - FROM `'. $this->getTableName() .'` |
|
83 | - WHERE `' . $compareCol . '` = ? |
|
81 | + SELECT `' . $fetchCol.'` |
|
82 | + FROM `'. $this->getTableName().'` |
|
83 | + WHERE `' . $compareCol.'` = ? |
|
84 | 84 | '); |
85 | 85 | |
86 | 86 | $res = $query->execute(array($search)); |
87 | - if($res !== false) { |
|
87 | + if ($res !== false) { |
|
88 | 88 | return $query->fetchColumn(); |
89 | 89 | } |
90 | 90 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function setDNbyUUID($fdn, $uuid) { |
122 | 122 | $query = $this->dbc->prepare(' |
123 | - UPDATE `' . $this->getTableName() . '` |
|
123 | + UPDATE `' . $this->getTableName().'` |
|
124 | 124 | SET `ldap_dn` = ? |
125 | 125 | WHERE `directory_uuid` = ? |
126 | 126 | '); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function setUUIDbyDN($uuid, $fdn) { |
141 | 141 | $query = $this->dbc->prepare(' |
142 | - UPDATE `' . $this->getTableName() . '` |
|
142 | + UPDATE `' . $this->getTableName().'` |
|
143 | 143 | SET `directory_uuid` = ? |
144 | 144 | WHERE `ldap_dn` = ? |
145 | 145 | '); |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | public function getNamesBySearch($search, $prefixMatch = "", $postfixMatch = "") { |
167 | 167 | $query = $this->dbc->prepare(' |
168 | 168 | SELECT `owncloud_name` |
169 | - FROM `'. $this->getTableName() .'` |
|
169 | + FROM `'. $this->getTableName().'` |
|
170 | 170 | WHERE `owncloud_name` LIKE ? |
171 | 171 | '); |
172 | 172 | |
173 | 173 | $res = $query->execute(array($prefixMatch.$this->dbc->escapeLikeParameter($search).$postfixMatch)); |
174 | 174 | $names = array(); |
175 | - if($res !== false) { |
|
176 | - while($row = $query->fetch()) { |
|
175 | + if ($res !== false) { |
|
176 | + while ($row = $query->fetch()) { |
|
177 | 177 | $names[] = $row['owncloud_name']; |
178 | 178 | } |
179 | 179 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | `ldap_dn` AS `dn`, |
212 | 212 | `owncloud_name` AS `name`, |
213 | 213 | `directory_uuid` AS `uuid` |
214 | - FROM `' . $this->getTableName() . '`', |
|
214 | + FROM `' . $this->getTableName().'`', |
|
215 | 215 | $limit, |
216 | 216 | $offset |
217 | 217 | ); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @return bool |
229 | 229 | */ |
230 | 230 | public function map($fdn, $name, $uuid) { |
231 | - if(mb_strlen($fdn) > 255) { |
|
231 | + if (mb_strlen($fdn) > 255) { |
|
232 | 232 | \OC::$server->getLogger()->error( |
233 | 233 | 'Cannot map, because the DN exceeds 255 characters: {dn}', |
234 | 234 | [ |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | try { |
249 | 249 | $result = $this->dbc->insertIfNotExist($this->getTableName(), $row); |
250 | 250 | // insertIfNotExist returns values as int |
251 | - return (bool)$result; |
|
251 | + return (bool) $result; |
|
252 | 252 | } catch (\Exception $e) { |
253 | 253 | return false; |
254 | 254 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function unmap($name) { |
263 | 263 | $query = $this->dbc->prepare(' |
264 | - DELETE FROM `'. $this->getTableName() .'` |
|
264 | + DELETE FROM `'. $this->getTableName().'` |
|
265 | 265 | WHERE `owncloud_name` = ?'); |
266 | 266 | |
267 | 267 | return $this->modify($query, array($name)); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | public function clear() { |
275 | 275 | $sql = $this->dbc |
276 | 276 | ->getDatabasePlatform() |
277 | - ->getTruncateTableSQL('`' . $this->getTableName() . '`'); |
|
277 | + ->getTruncateTableSQL('`'.$this->getTableName().'`'); |
|
278 | 278 | return $this->dbc->prepare($sql)->execute(); |
279 | 279 | } |
280 | 280 | } |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function __construct($serverConfigPrefixes, ILDAPWrapper $ldap) { |
38 | 38 | parent::__construct($ldap); |
39 | - foreach($serverConfigPrefixes as $configPrefix) { |
|
39 | + foreach ($serverConfigPrefixes as $configPrefix) { |
|
40 | 40 | $this->backends[$configPrefix] = |
41 | 41 | new \OCA\User_LDAP\Group_LDAP($this->getAccess($configPrefix)); |
42 | - if(is_null($this->refBackend)) { |
|
42 | + if (is_null($this->refBackend)) { |
|
43 | 43 | $this->refBackend = &$this->backends[$configPrefix]; |
44 | 44 | } |
45 | 45 | } |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function walkBackends($gid, $method, $parameters) { |
56 | 56 | $cacheKey = $this->getGroupCacheKey($gid); |
57 | - foreach($this->backends as $configPrefix => $backend) { |
|
58 | - if($result = call_user_func_array(array($backend, $method), $parameters)) { |
|
57 | + foreach ($this->backends as $configPrefix => $backend) { |
|
58 | + if ($result = call_user_func_array(array($backend, $method), $parameters)) { |
|
59 | 59 | $this->writeToCache($cacheKey, $configPrefix); |
60 | 60 | return $result; |
61 | 61 | } |
@@ -72,20 +72,20 @@ discard block |
||
72 | 72 | * @return mixed, the result of the method or false |
73 | 73 | */ |
74 | 74 | protected function callOnLastSeenOn($gid, $method, $parameters, $passOnWhen) { |
75 | - $cacheKey = $this->getGroupCacheKey($gid);; |
|
75 | + $cacheKey = $this->getGroupCacheKey($gid); ; |
|
76 | 76 | $prefix = $this->getFromCache($cacheKey); |
77 | 77 | //in case the uid has been found in the past, try this stored connection first |
78 | - if(!is_null($prefix)) { |
|
79 | - if(isset($this->backends[$prefix])) { |
|
78 | + if (!is_null($prefix)) { |
|
79 | + if (isset($this->backends[$prefix])) { |
|
80 | 80 | $result = call_user_func_array(array($this->backends[$prefix], $method), $parameters); |
81 | - if($result === $passOnWhen) { |
|
81 | + if ($result === $passOnWhen) { |
|
82 | 82 | //not found here, reset cache to null if group vanished |
83 | 83 | //because sometimes methods return false with a reason |
84 | 84 | $groupExists = call_user_func_array( |
85 | 85 | array($this->backends[$prefix], 'groupExists'), |
86 | 86 | array($gid) |
87 | 87 | ); |
88 | - if(!$groupExists) { |
|
88 | + if (!$groupExists) { |
|
89 | 89 | $this->writeToCache($cacheKey, null); |
90 | 90 | } |
91 | 91 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | public function getUserGroups($uid) { |
119 | 119 | $groups = array(); |
120 | 120 | |
121 | - foreach($this->backends as $backend) { |
|
121 | + foreach ($this->backends as $backend) { |
|
122 | 122 | $backendGroups = $backend->getUserGroups($uid); |
123 | 123 | if (is_array($backendGroups)) { |
124 | 124 | $groups = array_merge($groups, $backendGroups); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { |
136 | 136 | $users = array(); |
137 | 137 | |
138 | - foreach($this->backends as $backend) { |
|
138 | + foreach ($this->backends as $backend) { |
|
139 | 139 | $backendUsers = $backend->usersInGroup($gid, $search, $limit, $offset); |
140 | 140 | if (is_array($backendUsers)) { |
141 | 141 | $users = array_merge($users, $backendUsers); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function getGroups($search = '', $limit = -1, $offset = 0) { |
166 | 166 | $groups = array(); |
167 | 167 | |
168 | - foreach($this->backends as $backend) { |
|
168 | + foreach ($this->backends as $backend) { |
|
169 | 169 | $backendGroups = $backend->getGroups($search, $limit, $offset); |
170 | 170 | if (is_array($backendGroups)) { |
171 | 171 | $groups = array_merge($groups, $backendGroups); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function __construct(Configuration $configuration, ILDAPWrapper $ldap, Access $access) { |
68 | 68 | parent::__construct($ldap); |
69 | 69 | $this->configuration = $configuration; |
70 | - if(is_null(Wizard::$l)) { |
|
70 | + if (is_null(Wizard::$l)) { |
|
71 | 71 | Wizard::$l = \OC::$server->getL10N('user_ldap'); |
72 | 72 | } |
73 | 73 | $this->access = $access; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | public function __destruct() { |
78 | - if($this->result->hasChanges()) { |
|
78 | + if ($this->result->hasChanges()) { |
|
79 | 79 | $this->configuration->saveConfiguration(); |
80 | 80 | } |
81 | 81 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function countEntries($filter, $type) { |
92 | 92 | $reqs = array('ldapHost', 'ldapPort', 'ldapBase'); |
93 | - if($type === 'users') { |
|
93 | + if ($type === 'users') { |
|
94 | 94 | $reqs[] = 'ldapUserFilter'; |
95 | 95 | } |
96 | - if(!$this->checkRequirements($reqs)) { |
|
96 | + if (!$this->checkRequirements($reqs)) { |
|
97 | 97 | throw new \Exception('Requirements not met', 400); |
98 | 98 | } |
99 | 99 | |
100 | 100 | $attr = array('dn'); // default |
101 | 101 | $limit = 1001; |
102 | - if($type === 'groups') { |
|
103 | - $result = $this->access->countGroups($filter, $attr, $limit); |
|
104 | - } else if($type === 'users') { |
|
102 | + if ($type === 'groups') { |
|
103 | + $result = $this->access->countGroups($filter, $attr, $limit); |
|
104 | + } else if ($type === 'users') { |
|
105 | 105 | $result = $this->access->countUsers($filter, $attr, $limit); |
106 | 106 | } else if ($type === 'objects') { |
107 | 107 | $result = $this->access->countObjects($limit); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | private function formatCountResult($count) { |
123 | 123 | $formatted = ($count !== false) ? $count : 0; |
124 | - if($formatted > 1000) { |
|
124 | + if ($formatted > 1000) { |
|
125 | 125 | $formatted = '> 1000'; |
126 | 126 | } |
127 | 127 | return $formatted; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | public function countGroups() { |
131 | 131 | $filter = $this->configuration->ldapGroupFilter; |
132 | 132 | |
133 | - if(empty($filter)) { |
|
133 | + if (empty($filter)) { |
|
134 | 134 | $output = self::$l->n('%s group found', '%s groups found', 0, array(0)); |
135 | 135 | $this->result->addChange('ldap_group_count', $output); |
136 | 136 | return $this->result; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $groupsTotal = $this->formatCountResult($this->countEntries($filter, 'groups')); |
141 | 141 | } catch (\Exception $e) { |
142 | 142 | //400 can be ignored, 500 is forwarded |
143 | - if($e->getCode() === 500) { |
|
143 | + if ($e->getCode() === 500) { |
|
144 | 144 | throw $e; |
145 | 145 | } |
146 | 146 | return false; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function countInBaseDN() { |
173 | 173 | // we don't need to provide a filter in this case |
174 | 174 | $total = $this->countEntries(null, 'objects'); |
175 | - if($total === false) { |
|
175 | + if ($total === false) { |
|
176 | 176 | throw new \Exception('invalid results received'); |
177 | 177 | } |
178 | 178 | $this->result->addChange('ldap_test_base', $total); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @return int|bool |
187 | 187 | */ |
188 | 188 | public function countUsersWithAttribute($attr, $existsCheck = false) { |
189 | - if(!$this->checkRequirements(array('ldapHost', |
|
189 | + if (!$this->checkRequirements(array('ldapHost', |
|
190 | 190 | 'ldapPort', |
191 | 191 | 'ldapBase', |
192 | 192 | 'ldapUserFilter', |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $filter = $this->access->combineFilterWithAnd(array( |
198 | 198 | $this->configuration->ldapUserFilter, |
199 | - $attr . '=*' |
|
199 | + $attr.'=*' |
|
200 | 200 | )); |
201 | 201 | |
202 | 202 | $limit = ($existsCheck === false) ? null : 1; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @throws \Exception |
212 | 212 | */ |
213 | 213 | public function detectUserDisplayNameAttribute() { |
214 | - if(!$this->checkRequirements(array('ldapHost', |
|
214 | + if (!$this->checkRequirements(array('ldapHost', |
|
215 | 215 | 'ldapPort', |
216 | 216 | 'ldapBase', |
217 | 217 | 'ldapUserFilter', |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // most likely not the default value with upper case N, |
225 | 225 | // verify it still produces a result |
226 | 226 | $count = intval($this->countUsersWithAttribute($attr, true)); |
227 | - if($count > 0) { |
|
227 | + if ($count > 0) { |
|
228 | 228 | //no change, but we sent it back to make sure the user interface |
229 | 229 | //is still correct, even if the ajax call was cancelled meanwhile |
230 | 230 | $this->result->addChange('ldap_display_name', $attr); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | foreach ($displayNameAttrs as $attr) { |
238 | 238 | $count = intval($this->countUsersWithAttribute($attr, true)); |
239 | 239 | |
240 | - if($count > 0) { |
|
240 | + if ($count > 0) { |
|
241 | 241 | $this->applyFind('ldap_display_name', $attr); |
242 | 242 | return $this->result; |
243 | 243 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return WizardResult|bool |
254 | 254 | */ |
255 | 255 | public function detectEmailAttribute() { |
256 | - if(!$this->checkRequirements(array('ldapHost', |
|
256 | + if (!$this->checkRequirements(array('ldapHost', |
|
257 | 257 | 'ldapPort', |
258 | 258 | 'ldapBase', |
259 | 259 | 'ldapUserFilter', |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $attr = $this->configuration->ldapEmailAttribute; |
265 | 265 | if ($attr !== '') { |
266 | 266 | $count = intval($this->countUsersWithAttribute($attr, true)); |
267 | - if($count > 0) { |
|
267 | + if ($count > 0) { |
|
268 | 268 | return false; |
269 | 269 | } |
270 | 270 | $writeLog = true; |
@@ -275,19 +275,19 @@ discard block |
||
275 | 275 | $emailAttributes = array('mail', 'mailPrimaryAddress'); |
276 | 276 | $winner = ''; |
277 | 277 | $maxUsers = 0; |
278 | - foreach($emailAttributes as $attr) { |
|
278 | + foreach ($emailAttributes as $attr) { |
|
279 | 279 | $count = $this->countUsersWithAttribute($attr); |
280 | - if($count > $maxUsers) { |
|
280 | + if ($count > $maxUsers) { |
|
281 | 281 | $maxUsers = $count; |
282 | 282 | $winner = $attr; |
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
286 | - if($winner !== '') { |
|
286 | + if ($winner !== '') { |
|
287 | 287 | $this->applyFind('ldap_email_attr', $winner); |
288 | - if($writeLog) { |
|
289 | - \OCP\Util::writeLog('user_ldap', 'The mail attribute has ' . |
|
290 | - 'automatically been reset, because the original value ' . |
|
288 | + if ($writeLog) { |
|
289 | + \OCP\Util::writeLog('user_ldap', 'The mail attribute has '. |
|
290 | + 'automatically been reset, because the original value '. |
|
291 | 291 | 'did not return any results.', \OCP\Util::INFO); |
292 | 292 | } |
293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @throws \Exception |
301 | 301 | */ |
302 | 302 | public function determineAttributes() { |
303 | - if(!$this->checkRequirements(array('ldapHost', |
|
303 | + if (!$this->checkRequirements(array('ldapHost', |
|
304 | 304 | 'ldapPort', |
305 | 305 | 'ldapBase', |
306 | 306 | 'ldapUserFilter', |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $this->result->addOptions('ldap_loginfilter_attributes', $attributes); |
317 | 317 | |
318 | 318 | $selected = $this->configuration->ldapLoginFilterAttributes; |
319 | - if(is_array($selected) && !empty($selected)) { |
|
319 | + if (is_array($selected) && !empty($selected)) { |
|
320 | 320 | $this->result->addChange('ldap_loginfilter_attributes', $selected); |
321 | 321 | } |
322 | 322 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @throws \Exception |
330 | 330 | */ |
331 | 331 | private function getUserAttributes() { |
332 | - if(!$this->checkRequirements(array('ldapHost', |
|
332 | + if (!$this->checkRequirements(array('ldapHost', |
|
333 | 333 | 'ldapPort', |
334 | 334 | 'ldapBase', |
335 | 335 | 'ldapUserFilter', |
@@ -337,20 +337,20 @@ discard block |
||
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | $cr = $this->getConnection(); |
340 | - if(!$cr) { |
|
340 | + if (!$cr) { |
|
341 | 341 | throw new \Exception('Could not connect to LDAP'); |
342 | 342 | } |
343 | 343 | |
344 | 344 | $base = $this->configuration->ldapBase[0]; |
345 | 345 | $filter = $this->configuration->ldapUserFilter; |
346 | 346 | $rr = $this->ldap->search($cr, $base, $filter, array(), 1, 1); |
347 | - if(!$this->ldap->isResource($rr)) { |
|
347 | + if (!$this->ldap->isResource($rr)) { |
|
348 | 348 | return false; |
349 | 349 | } |
350 | 350 | $er = $this->ldap->firstEntry($cr, $rr); |
351 | 351 | $attributes = $this->ldap->getAttributes($cr, $er); |
352 | 352 | $pureAttributes = array(); |
353 | - for($i = 0; $i < $attributes['count']; $i++) { |
|
353 | + for ($i = 0; $i < $attributes['count']; $i++) { |
|
354 | 354 | $pureAttributes[] = $attributes[$i]; |
355 | 355 | } |
356 | 356 | |
@@ -385,23 +385,23 @@ discard block |
||
385 | 385 | * @throws \Exception |
386 | 386 | */ |
387 | 387 | private function determineGroups($dbKey, $confKey, $testMemberOf = true) { |
388 | - if(!$this->checkRequirements(array('ldapHost', |
|
388 | + if (!$this->checkRequirements(array('ldapHost', |
|
389 | 389 | 'ldapPort', |
390 | 390 | 'ldapBase', |
391 | 391 | ))) { |
392 | 392 | return false; |
393 | 393 | } |
394 | 394 | $cr = $this->getConnection(); |
395 | - if(!$cr) { |
|
395 | + if (!$cr) { |
|
396 | 396 | throw new \Exception('Could not connect to LDAP'); |
397 | 397 | } |
398 | 398 | |
399 | 399 | $this->fetchGroups($dbKey, $confKey); |
400 | 400 | |
401 | - if($testMemberOf) { |
|
401 | + if ($testMemberOf) { |
|
402 | 402 | $this->configuration->hasMemberOfFilterSupport = $this->testMemberOf(); |
403 | 403 | $this->result->markChange(); |
404 | - if(!$this->configuration->hasMemberOfFilterSupport) { |
|
404 | + if (!$this->configuration->hasMemberOfFilterSupport) { |
|
405 | 405 | throw new \Exception('memberOf is not supported by the server'); |
406 | 406 | } |
407 | 407 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $obclasses = array('posixGroup', 'group', 'zimbraDistributionList', 'groupOfNames'); |
422 | 422 | |
423 | 423 | $filterParts = array(); |
424 | - foreach($obclasses as $obclass) { |
|
424 | + foreach ($obclasses as $obclass) { |
|
425 | 425 | $filterParts[] = 'objectclass='.$obclass; |
426 | 426 | } |
427 | 427 | //we filter for everything |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | // we need to request dn additionally here, otherwise memberOf |
439 | 439 | // detection will fail later |
440 | 440 | $result = $this->access->searchGroups($filter, array('cn', 'dn'), $limit, $offset); |
441 | - foreach($result as $item) { |
|
442 | - if(!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
441 | + foreach ($result as $item) { |
|
442 | + if (!isset($item['cn']) && !is_array($item['cn']) && !isset($item['cn'][0])) { |
|
443 | 443 | // just in case - no issue known |
444 | 444 | continue; |
445 | 445 | } |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $offset += $limit; |
450 | 450 | } while ($this->access->hasMoreResults()); |
451 | 451 | |
452 | - if(count($groupNames) > 0) { |
|
452 | + if (count($groupNames) > 0) { |
|
453 | 453 | natsort($groupNames); |
454 | 454 | $this->result->addOptions($dbKey, array_values($groupNames)); |
455 | 455 | } else { |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | } |
458 | 458 | |
459 | 459 | $setFeatures = $this->configuration->$confKey; |
460 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
460 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
461 | 461 | //something is already configured? pre-select it. |
462 | 462 | $this->result->addChange($dbKey, $setFeatures); |
463 | 463 | } |
@@ -465,14 +465,14 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | public function determineGroupMemberAssoc() { |
468 | - if(!$this->checkRequirements(array('ldapHost', |
|
468 | + if (!$this->checkRequirements(array('ldapHost', |
|
469 | 469 | 'ldapPort', |
470 | 470 | 'ldapGroupFilter', |
471 | 471 | ))) { |
472 | 472 | return false; |
473 | 473 | } |
474 | 474 | $attribute = $this->detectGroupMemberAssoc(); |
475 | - if($attribute === false) { |
|
475 | + if ($attribute === false) { |
|
476 | 476 | return false; |
477 | 477 | } |
478 | 478 | $this->configuration->setConfiguration(array('ldapGroupMemberAssocAttr' => $attribute)); |
@@ -487,14 +487,14 @@ discard block |
||
487 | 487 | * @throws \Exception |
488 | 488 | */ |
489 | 489 | public function determineGroupObjectClasses() { |
490 | - if(!$this->checkRequirements(array('ldapHost', |
|
490 | + if (!$this->checkRequirements(array('ldapHost', |
|
491 | 491 | 'ldapPort', |
492 | 492 | 'ldapBase', |
493 | 493 | ))) { |
494 | 494 | return false; |
495 | 495 | } |
496 | 496 | $cr = $this->getConnection(); |
497 | - if(!$cr) { |
|
497 | + if (!$cr) { |
|
498 | 498 | throw new \Exception('Could not connect to LDAP'); |
499 | 499 | } |
500 | 500 | |
@@ -514,14 +514,14 @@ discard block |
||
514 | 514 | * @throws \Exception |
515 | 515 | */ |
516 | 516 | public function determineUserObjectClasses() { |
517 | - if(!$this->checkRequirements(array('ldapHost', |
|
517 | + if (!$this->checkRequirements(array('ldapHost', |
|
518 | 518 | 'ldapPort', |
519 | 519 | 'ldapBase', |
520 | 520 | ))) { |
521 | 521 | return false; |
522 | 522 | } |
523 | 523 | $cr = $this->getConnection(); |
524 | - if(!$cr) { |
|
524 | + if (!$cr) { |
|
525 | 525 | throw new \Exception('Could not connect to LDAP'); |
526 | 526 | } |
527 | 527 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | * @throws \Exception |
545 | 545 | */ |
546 | 546 | public function getGroupFilter() { |
547 | - if(!$this->checkRequirements(array('ldapHost', |
|
547 | + if (!$this->checkRequirements(array('ldapHost', |
|
548 | 548 | 'ldapPort', |
549 | 549 | 'ldapBase', |
550 | 550 | ))) { |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @throws \Exception |
569 | 569 | */ |
570 | 570 | public function getUserListFilter() { |
571 | - if(!$this->checkRequirements(array('ldapHost', |
|
571 | + if (!$this->checkRequirements(array('ldapHost', |
|
572 | 572 | 'ldapPort', |
573 | 573 | 'ldapBase', |
574 | 574 | ))) { |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $this->applyFind('ldap_display_name', $d['ldap_display_name']); |
582 | 582 | } |
583 | 583 | $filter = $this->composeLdapFilter(self::LFILTER_USER_LIST); |
584 | - if(!$filter) { |
|
584 | + if (!$filter) { |
|
585 | 585 | throw new \Exception('Cannot create filter'); |
586 | 586 | } |
587 | 587 | |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * @throws \Exception |
595 | 595 | */ |
596 | 596 | public function getUserLoginFilter() { |
597 | - if(!$this->checkRequirements(array('ldapHost', |
|
597 | + if (!$this->checkRequirements(array('ldapHost', |
|
598 | 598 | 'ldapPort', |
599 | 599 | 'ldapBase', |
600 | 600 | 'ldapUserFilter', |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | } |
604 | 604 | |
605 | 605 | $filter = $this->composeLdapFilter(self::LFILTER_LOGIN); |
606 | - if(!$filter) { |
|
606 | + if (!$filter) { |
|
607 | 607 | throw new \Exception('Cannot create filter'); |
608 | 608 | } |
609 | 609 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | * @throws \Exception |
618 | 618 | */ |
619 | 619 | public function testLoginName($loginName) { |
620 | - if(!$this->checkRequirements(array('ldapHost', |
|
620 | + if (!$this->checkRequirements(array('ldapHost', |
|
621 | 621 | 'ldapPort', |
622 | 622 | 'ldapBase', |
623 | 623 | 'ldapLoginFilter', |
@@ -626,17 +626,17 @@ discard block |
||
626 | 626 | } |
627 | 627 | |
628 | 628 | $cr = $this->access->connection->getConnectionResource(); |
629 | - if(!$this->ldap->isResource($cr)) { |
|
629 | + if (!$this->ldap->isResource($cr)) { |
|
630 | 630 | throw new \Exception('connection error'); |
631 | 631 | } |
632 | 632 | |
633 | - if(mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
633 | + if (mb_strpos($this->access->connection->ldapLoginFilter, '%uid', 0, 'UTF-8') |
|
634 | 634 | === false) { |
635 | 635 | throw new \Exception('missing placeholder'); |
636 | 636 | } |
637 | 637 | |
638 | 638 | $users = $this->access->countUsersByLoginName($loginName); |
639 | - if($this->ldap->errno($cr) !== 0) { |
|
639 | + if ($this->ldap->errno($cr) !== 0) { |
|
640 | 640 | throw new \Exception($this->ldap->error($cr)); |
641 | 641 | } |
642 | 642 | $filter = str_replace('%uid', $loginName, $this->access->connection->ldapLoginFilter); |
@@ -651,22 +651,22 @@ discard block |
||
651 | 651 | * @throws \Exception |
652 | 652 | */ |
653 | 653 | public function guessPortAndTLS() { |
654 | - if(!$this->checkRequirements(array('ldapHost', |
|
654 | + if (!$this->checkRequirements(array('ldapHost', |
|
655 | 655 | ))) { |
656 | 656 | return false; |
657 | 657 | } |
658 | 658 | $this->checkHost(); |
659 | 659 | $portSettings = $this->getPortSettingsToTry(); |
660 | 660 | |
661 | - if(!is_array($portSettings)) { |
|
661 | + if (!is_array($portSettings)) { |
|
662 | 662 | throw new \Exception(print_r($portSettings, true)); |
663 | 663 | } |
664 | 664 | |
665 | 665 | //proceed from the best configuration and return on first success |
666 | - foreach($portSettings as $setting) { |
|
666 | + foreach ($portSettings as $setting) { |
|
667 | 667 | $p = $setting['port']; |
668 | 668 | $t = $setting['tls']; |
669 | - \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '. $p . ', TLS '. $t, \OCP\Util::DEBUG); |
|
669 | + \OCP\Util::writeLog('user_ldap', 'Wiz: trying port '.$p.', TLS '.$t, \OCP\Util::DEBUG); |
|
670 | 670 | //connectAndBind may throw Exception, it needs to be catched by the |
671 | 671 | //callee of this method |
672 | 672 | |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | // any reply other than -1 (= cannot connect) is already okay, |
677 | 677 | // because then we found the server |
678 | 678 | // unavailable startTLS returns -11 |
679 | - if($e->getCode() > 0) { |
|
679 | + if ($e->getCode() > 0) { |
|
680 | 680 | $settingsFound = true; |
681 | 681 | } else { |
682 | 682 | throw $e; |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | 'ldapTLS' => intval($t) |
690 | 690 | ); |
691 | 691 | $this->configuration->setConfiguration($config); |
692 | - \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, \OCP\Util::DEBUG); |
|
692 | + \OCP\Util::writeLog('user_ldap', 'Wiz: detected Port '.$p, \OCP\Util::DEBUG); |
|
693 | 693 | $this->result->addChange('ldap_port', $p); |
694 | 694 | return $this->result; |
695 | 695 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @return WizardResult|false WizardResult on success, false otherwise |
705 | 705 | */ |
706 | 706 | public function guessBaseDN() { |
707 | - if(!$this->checkRequirements(array('ldapHost', |
|
707 | + if (!$this->checkRequirements(array('ldapHost', |
|
708 | 708 | 'ldapPort', |
709 | 709 | ))) { |
710 | 710 | return false; |
@@ -713,9 +713,9 @@ discard block |
||
713 | 713 | //check whether a DN is given in the agent name (99.9% of all cases) |
714 | 714 | $base = null; |
715 | 715 | $i = stripos($this->configuration->ldapAgentName, 'dc='); |
716 | - if($i !== false) { |
|
716 | + if ($i !== false) { |
|
717 | 717 | $base = substr($this->configuration->ldapAgentName, $i); |
718 | - if($this->testBaseDN($base)) { |
|
718 | + if ($this->testBaseDN($base)) { |
|
719 | 719 | $this->applyFind('ldap_base', $base); |
720 | 720 | return $this->result; |
721 | 721 | } |
@@ -726,13 +726,13 @@ discard block |
||
726 | 726 | //a base DN |
727 | 727 | $helper = new Helper(\OC::$server->getConfig()); |
728 | 728 | $domain = $helper->getDomainFromURL($this->configuration->ldapHost); |
729 | - if(!$domain) { |
|
729 | + if (!$domain) { |
|
730 | 730 | return false; |
731 | 731 | } |
732 | 732 | |
733 | 733 | $dparts = explode('.', $domain); |
734 | - while(count($dparts) > 0) { |
|
735 | - $base2 = 'dc=' . implode(',dc=', $dparts); |
|
734 | + while (count($dparts) > 0) { |
|
735 | + $base2 = 'dc='.implode(',dc=', $dparts); |
|
736 | 736 | if ($base !== $base2 && $this->testBaseDN($base2)) { |
737 | 737 | $this->applyFind('ldap_base', $base2); |
738 | 738 | return $this->result; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | $hostInfo = parse_url($host); |
766 | 766 | |
767 | 767 | //removes Port from Host |
768 | - if(is_array($hostInfo) && isset($hostInfo['port'])) { |
|
768 | + if (is_array($hostInfo) && isset($hostInfo['port'])) { |
|
769 | 769 | $port = $hostInfo['port']; |
770 | 770 | $host = str_replace(':'.$port, '', $host); |
771 | 771 | $this->applyFind('ldap_host', $host); |
@@ -782,30 +782,30 @@ discard block |
||
782 | 782 | private function detectGroupMemberAssoc() { |
783 | 783 | $possibleAttrs = array('uniqueMember', 'memberUid', 'member'); |
784 | 784 | $filter = $this->configuration->ldapGroupFilter; |
785 | - if(empty($filter)) { |
|
785 | + if (empty($filter)) { |
|
786 | 786 | return false; |
787 | 787 | } |
788 | 788 | $cr = $this->getConnection(); |
789 | - if(!$cr) { |
|
789 | + if (!$cr) { |
|
790 | 790 | throw new \Exception('Could not connect to LDAP'); |
791 | 791 | } |
792 | 792 | $base = $this->configuration->ldapBase[0]; |
793 | 793 | $rr = $this->ldap->search($cr, $base, $filter, $possibleAttrs, 0, 1000); |
794 | - if(!$this->ldap->isResource($rr)) { |
|
794 | + if (!$this->ldap->isResource($rr)) { |
|
795 | 795 | return false; |
796 | 796 | } |
797 | 797 | $er = $this->ldap->firstEntry($cr, $rr); |
798 | - while(is_resource($er)) { |
|
798 | + while (is_resource($er)) { |
|
799 | 799 | $this->ldap->getDN($cr, $er); |
800 | 800 | $attrs = $this->ldap->getAttributes($cr, $er); |
801 | 801 | $result = array(); |
802 | 802 | $possibleAttrsCount = count($possibleAttrs); |
803 | - for($i = 0; $i < $possibleAttrsCount; $i++) { |
|
804 | - if(isset($attrs[$possibleAttrs[$i]])) { |
|
803 | + for ($i = 0; $i < $possibleAttrsCount; $i++) { |
|
804 | + if (isset($attrs[$possibleAttrs[$i]])) { |
|
805 | 805 | $result[$possibleAttrs[$i]] = $attrs[$possibleAttrs[$i]]['count']; |
806 | 806 | } |
807 | 807 | } |
808 | - if(!empty($result)) { |
|
808 | + if (!empty($result)) { |
|
809 | 809 | natsort($result); |
810 | 810 | return key($result); |
811 | 811 | } |
@@ -824,14 +824,14 @@ discard block |
||
824 | 824 | */ |
825 | 825 | private function testBaseDN($base) { |
826 | 826 | $cr = $this->getConnection(); |
827 | - if(!$cr) { |
|
827 | + if (!$cr) { |
|
828 | 828 | throw new \Exception('Could not connect to LDAP'); |
829 | 829 | } |
830 | 830 | |
831 | 831 | //base is there, let's validate it. If we search for anything, we should |
832 | 832 | //get a result set > 0 on a proper base |
833 | 833 | $rr = $this->ldap->search($cr, $base, 'objectClass=*', array('dn'), 0, 1); |
834 | - if(!$this->ldap->isResource($rr)) { |
|
834 | + if (!$this->ldap->isResource($rr)) { |
|
835 | 835 | $errorNo = $this->ldap->errno($cr); |
836 | 836 | $errorMsg = $this->ldap->error($cr); |
837 | 837 | \OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base. |
@@ -853,11 +853,11 @@ discard block |
||
853 | 853 | */ |
854 | 854 | private function testMemberOf() { |
855 | 855 | $cr = $this->getConnection(); |
856 | - if(!$cr) { |
|
856 | + if (!$cr) { |
|
857 | 857 | throw new \Exception('Could not connect to LDAP'); |
858 | 858 | } |
859 | 859 | $result = $this->access->countUsers('memberOf=*', array('memberOf'), 1); |
860 | - if(is_int($result) && $result > 0) { |
|
860 | + if (is_int($result) && $result > 0) { |
|
861 | 861 | return true; |
862 | 862 | } |
863 | 863 | return false; |
@@ -878,27 +878,27 @@ discard block |
||
878 | 878 | case self::LFILTER_USER_LIST: |
879 | 879 | $objcs = $this->configuration->ldapUserFilterObjectclass; |
880 | 880 | //glue objectclasses |
881 | - if(is_array($objcs) && count($objcs) > 0) { |
|
881 | + if (is_array($objcs) && count($objcs) > 0) { |
|
882 | 882 | $filter .= '(|'; |
883 | - foreach($objcs as $objc) { |
|
884 | - $filter .= '(objectclass=' . $objc . ')'; |
|
883 | + foreach ($objcs as $objc) { |
|
884 | + $filter .= '(objectclass='.$objc.')'; |
|
885 | 885 | } |
886 | 886 | $filter .= ')'; |
887 | 887 | $parts++; |
888 | 888 | } |
889 | 889 | //glue group memberships |
890 | - if($this->configuration->hasMemberOfFilterSupport) { |
|
890 | + if ($this->configuration->hasMemberOfFilterSupport) { |
|
891 | 891 | $cns = $this->configuration->ldapUserFilterGroups; |
892 | - if(is_array($cns) && count($cns) > 0) { |
|
892 | + if (is_array($cns) && count($cns) > 0) { |
|
893 | 893 | $filter .= '(|'; |
894 | 894 | $cr = $this->getConnection(); |
895 | - if(!$cr) { |
|
895 | + if (!$cr) { |
|
896 | 896 | throw new \Exception('Could not connect to LDAP'); |
897 | 897 | } |
898 | 898 | $base = $this->configuration->ldapBase[0]; |
899 | - foreach($cns as $cn) { |
|
900 | - $rr = $this->ldap->search($cr, $base, 'cn=' . $cn, array('dn', 'primaryGroupToken')); |
|
901 | - if(!$this->ldap->isResource($rr)) { |
|
899 | + foreach ($cns as $cn) { |
|
900 | + $rr = $this->ldap->search($cr, $base, 'cn='.$cn, array('dn', 'primaryGroupToken')); |
|
901 | + if (!$this->ldap->isResource($rr)) { |
|
902 | 902 | continue; |
903 | 903 | } |
904 | 904 | $er = $this->ldap->firstEntry($cr, $rr); |
@@ -907,11 +907,11 @@ discard block |
||
907 | 907 | if ($dn == false || $dn === '') { |
908 | 908 | continue; |
909 | 909 | } |
910 | - $filterPart = '(memberof=' . $dn . ')'; |
|
911 | - if(isset($attrs['primaryGroupToken'])) { |
|
910 | + $filterPart = '(memberof='.$dn.')'; |
|
911 | + if (isset($attrs['primaryGroupToken'])) { |
|
912 | 912 | $pgt = $attrs['primaryGroupToken'][0]; |
913 | - $primaryFilterPart = '(primaryGroupID=' . $pgt .')'; |
|
914 | - $filterPart = '(|' . $filterPart . $primaryFilterPart . ')'; |
|
913 | + $primaryFilterPart = '(primaryGroupID='.$pgt.')'; |
|
914 | + $filterPart = '(|'.$filterPart.$primaryFilterPart.')'; |
|
915 | 915 | } |
916 | 916 | $filter .= $filterPart; |
917 | 917 | } |
@@ -920,8 +920,8 @@ discard block |
||
920 | 920 | $parts++; |
921 | 921 | } |
922 | 922 | //wrap parts in AND condition |
923 | - if($parts > 1) { |
|
924 | - $filter = '(&' . $filter . ')'; |
|
923 | + if ($parts > 1) { |
|
924 | + $filter = '(&'.$filter.')'; |
|
925 | 925 | } |
926 | 926 | if ($filter === '') { |
927 | 927 | $filter = '(objectclass=*)'; |
@@ -931,27 +931,27 @@ discard block |
||
931 | 931 | case self::LFILTER_GROUP_LIST: |
932 | 932 | $objcs = $this->configuration->ldapGroupFilterObjectclass; |
933 | 933 | //glue objectclasses |
934 | - if(is_array($objcs) && count($objcs) > 0) { |
|
934 | + if (is_array($objcs) && count($objcs) > 0) { |
|
935 | 935 | $filter .= '(|'; |
936 | - foreach($objcs as $objc) { |
|
937 | - $filter .= '(objectclass=' . $objc . ')'; |
|
936 | + foreach ($objcs as $objc) { |
|
937 | + $filter .= '(objectclass='.$objc.')'; |
|
938 | 938 | } |
939 | 939 | $filter .= ')'; |
940 | 940 | $parts++; |
941 | 941 | } |
942 | 942 | //glue group memberships |
943 | 943 | $cns = $this->configuration->ldapGroupFilterGroups; |
944 | - if(is_array($cns) && count($cns) > 0) { |
|
944 | + if (is_array($cns) && count($cns) > 0) { |
|
945 | 945 | $filter .= '(|'; |
946 | - foreach($cns as $cn) { |
|
947 | - $filter .= '(cn=' . $cn . ')'; |
|
946 | + foreach ($cns as $cn) { |
|
947 | + $filter .= '(cn='.$cn.')'; |
|
948 | 948 | } |
949 | 949 | $filter .= ')'; |
950 | 950 | } |
951 | 951 | $parts++; |
952 | 952 | //wrap parts in AND condition |
953 | - if($parts > 1) { |
|
954 | - $filter = '(&' . $filter . ')'; |
|
953 | + if ($parts > 1) { |
|
954 | + $filter = '(&'.$filter.')'; |
|
955 | 955 | } |
956 | 956 | break; |
957 | 957 | |
@@ -963,47 +963,47 @@ discard block |
||
963 | 963 | $userAttributes = array_change_key_case(array_flip($userAttributes)); |
964 | 964 | $parts = 0; |
965 | 965 | |
966 | - if($this->configuration->ldapLoginFilterUsername === '1') { |
|
966 | + if ($this->configuration->ldapLoginFilterUsername === '1') { |
|
967 | 967 | $attr = ''; |
968 | - if(isset($userAttributes['uid'])) { |
|
968 | + if (isset($userAttributes['uid'])) { |
|
969 | 969 | $attr = 'uid'; |
970 | - } else if(isset($userAttributes['samaccountname'])) { |
|
970 | + } else if (isset($userAttributes['samaccountname'])) { |
|
971 | 971 | $attr = 'samaccountname'; |
972 | - } else if(isset($userAttributes['cn'])) { |
|
972 | + } else if (isset($userAttributes['cn'])) { |
|
973 | 973 | //fallback |
974 | 974 | $attr = 'cn'; |
975 | 975 | } |
976 | 976 | if ($attr !== '') { |
977 | - $filterUsername = '(' . $attr . $loginpart . ')'; |
|
977 | + $filterUsername = '('.$attr.$loginpart.')'; |
|
978 | 978 | $parts++; |
979 | 979 | } |
980 | 980 | } |
981 | 981 | |
982 | 982 | $filterEmail = ''; |
983 | - if($this->configuration->ldapLoginFilterEmail === '1') { |
|
983 | + if ($this->configuration->ldapLoginFilterEmail === '1') { |
|
984 | 984 | $filterEmail = '(|(mailPrimaryAddress=%uid)(mail=%uid))'; |
985 | 985 | $parts++; |
986 | 986 | } |
987 | 987 | |
988 | 988 | $filterAttributes = ''; |
989 | 989 | $attrsToFilter = $this->configuration->ldapLoginFilterAttributes; |
990 | - if(is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
990 | + if (is_array($attrsToFilter) && count($attrsToFilter) > 0) { |
|
991 | 991 | $filterAttributes = '(|'; |
992 | - foreach($attrsToFilter as $attribute) { |
|
993 | - $filterAttributes .= '(' . $attribute . $loginpart . ')'; |
|
992 | + foreach ($attrsToFilter as $attribute) { |
|
993 | + $filterAttributes .= '('.$attribute.$loginpart.')'; |
|
994 | 994 | } |
995 | 995 | $filterAttributes .= ')'; |
996 | 996 | $parts++; |
997 | 997 | } |
998 | 998 | |
999 | 999 | $filterLogin = ''; |
1000 | - if($parts > 1) { |
|
1000 | + if ($parts > 1) { |
|
1001 | 1001 | $filterLogin = '(|'; |
1002 | 1002 | } |
1003 | 1003 | $filterLogin .= $filterUsername; |
1004 | 1004 | $filterLogin .= $filterEmail; |
1005 | 1005 | $filterLogin .= $filterAttributes; |
1006 | - if($parts > 1) { |
|
1006 | + if ($parts > 1) { |
|
1007 | 1007 | $filterLogin .= ')'; |
1008 | 1008 | } |
1009 | 1009 | |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | * @throws \Exception |
1026 | 1026 | */ |
1027 | 1027 | private function connectAndBind($port = 389, $tls = false, $ncc = false) { |
1028 | - if($ncc) { |
|
1028 | + if ($ncc) { |
|
1029 | 1029 | //No certificate check |
1030 | 1030 | //FIXME: undo afterwards |
1031 | 1031 | putenv('LDAPTLS_REQCERT=never'); |
@@ -1035,12 +1035,12 @@ discard block |
||
1035 | 1035 | \OCP\Util::writeLog('user_ldap', 'Wiz: Checking Host Info ', \OCP\Util::DEBUG); |
1036 | 1036 | $host = $this->configuration->ldapHost; |
1037 | 1037 | $hostInfo = parse_url($host); |
1038 | - if(!$hostInfo) { |
|
1038 | + if (!$hostInfo) { |
|
1039 | 1039 | throw new \Exception(self::$l->t('Invalid Host')); |
1040 | 1040 | } |
1041 | 1041 | \OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', \OCP\Util::DEBUG); |
1042 | 1042 | $cr = $this->ldap->connect($host, $port); |
1043 | - if(!is_resource($cr)) { |
|
1043 | + if (!is_resource($cr)) { |
|
1044 | 1044 | throw new \Exception(self::$l->t('Invalid Host')); |
1045 | 1045 | } |
1046 | 1046 | |
@@ -1051,9 +1051,9 @@ discard block |
||
1051 | 1051 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1052 | 1052 | |
1053 | 1053 | try { |
1054 | - if($tls) { |
|
1054 | + if ($tls) { |
|
1055 | 1055 | $isTlsWorking = @$this->ldap->startTls($cr); |
1056 | - if(!$isTlsWorking) { |
|
1056 | + if (!$isTlsWorking) { |
|
1057 | 1057 | return false; |
1058 | 1058 | } |
1059 | 1059 | } |
@@ -1067,20 +1067,20 @@ discard block |
||
1067 | 1067 | $errNo = $this->ldap->errno($cr); |
1068 | 1068 | $error = ldap_error($cr); |
1069 | 1069 | $this->ldap->unbind($cr); |
1070 | - } catch(ServerNotAvailableException $e) { |
|
1070 | + } catch (ServerNotAvailableException $e) { |
|
1071 | 1071 | return false; |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - if($login === true) { |
|
1074 | + if ($login === true) { |
|
1075 | 1075 | $this->ldap->unbind($cr); |
1076 | - if($ncc) { |
|
1076 | + if ($ncc) { |
|
1077 | 1077 | throw new \Exception('Certificate cannot be validated.'); |
1078 | 1078 | } |
1079 | - \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . intval($tls), \OCP\Util::DEBUG); |
|
1079 | + \OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '.$port.' TLS '.intval($tls), \OCP\Util::DEBUG); |
|
1080 | 1080 | return true; |
1081 | 1081 | } |
1082 | 1082 | |
1083 | - if($errNo === -1 || ($errNo === 2 && $ncc)) { |
|
1083 | + if ($errNo === -1 || ($errNo === 2 && $ncc)) { |
|
1084 | 1084 | //host, port or TLS wrong |
1085 | 1085 | return false; |
1086 | 1086 | } else if ($errNo === 2) { |
@@ -1110,9 +1110,9 @@ discard block |
||
1110 | 1110 | */ |
1111 | 1111 | private function checkRequirements($reqs) { |
1112 | 1112 | $this->checkAgentRequirements(); |
1113 | - foreach($reqs as $option) { |
|
1113 | + foreach ($reqs as $option) { |
|
1114 | 1114 | $value = $this->configuration->$option; |
1115 | - if(empty($value)) { |
|
1115 | + if (empty($value)) { |
|
1116 | 1116 | return false; |
1117 | 1117 | } |
1118 | 1118 | } |
@@ -1134,33 +1134,33 @@ discard block |
||
1134 | 1134 | $dnRead = array(); |
1135 | 1135 | $foundItems = array(); |
1136 | 1136 | $maxEntries = 0; |
1137 | - if(!is_array($this->configuration->ldapBase) |
|
1137 | + if (!is_array($this->configuration->ldapBase) |
|
1138 | 1138 | || !isset($this->configuration->ldapBase[0])) { |
1139 | 1139 | return false; |
1140 | 1140 | } |
1141 | 1141 | $base = $this->configuration->ldapBase[0]; |
1142 | 1142 | $cr = $this->getConnection(); |
1143 | - if(!$this->ldap->isResource($cr)) { |
|
1143 | + if (!$this->ldap->isResource($cr)) { |
|
1144 | 1144 | return false; |
1145 | 1145 | } |
1146 | 1146 | $lastFilter = null; |
1147 | - if(isset($filters[count($filters)-1])) { |
|
1148 | - $lastFilter = $filters[count($filters)-1]; |
|
1147 | + if (isset($filters[count($filters) - 1])) { |
|
1148 | + $lastFilter = $filters[count($filters) - 1]; |
|
1149 | 1149 | } |
1150 | - foreach($filters as $filter) { |
|
1151 | - if($lastFilter === $filter && count($foundItems) > 0) { |
|
1150 | + foreach ($filters as $filter) { |
|
1151 | + if ($lastFilter === $filter && count($foundItems) > 0) { |
|
1152 | 1152 | //skip when the filter is a wildcard and results were found |
1153 | 1153 | continue; |
1154 | 1154 | } |
1155 | 1155 | // 20k limit for performance and reason |
1156 | 1156 | $rr = $this->ldap->search($cr, $base, $filter, array($attr), 0, 20000); |
1157 | - if(!$this->ldap->isResource($rr)) { |
|
1157 | + if (!$this->ldap->isResource($rr)) { |
|
1158 | 1158 | continue; |
1159 | 1159 | } |
1160 | 1160 | $entries = $this->ldap->countEntries($cr, $rr); |
1161 | 1161 | $getEntryFunc = 'firstEntry'; |
1162 | - if(($entries !== false) && ($entries > 0)) { |
|
1163 | - if(!is_null($maxF) && $entries > $maxEntries) { |
|
1162 | + if (($entries !== false) && ($entries > 0)) { |
|
1163 | + if (!is_null($maxF) && $entries > $maxEntries) { |
|
1164 | 1164 | $maxEntries = $entries; |
1165 | 1165 | $maxF = $filter; |
1166 | 1166 | } |
@@ -1168,13 +1168,13 @@ discard block |
||
1168 | 1168 | do { |
1169 | 1169 | $entry = $this->ldap->$getEntryFunc($cr, $rr); |
1170 | 1170 | $getEntryFunc = 'nextEntry'; |
1171 | - if(!$this->ldap->isResource($entry)) { |
|
1171 | + if (!$this->ldap->isResource($entry)) { |
|
1172 | 1172 | continue 2; |
1173 | 1173 | } |
1174 | 1174 | $rr = $entry; //will be expected by nextEntry next round |
1175 | 1175 | $attributes = $this->ldap->getAttributes($cr, $entry); |
1176 | 1176 | $dn = $this->ldap->getDN($cr, $entry); |
1177 | - if($dn === false || in_array($dn, $dnRead)) { |
|
1177 | + if ($dn === false || in_array($dn, $dnRead)) { |
|
1178 | 1178 | continue; |
1179 | 1179 | } |
1180 | 1180 | $newItems = array(); |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | $foundItems = array_merge($foundItems, $newItems); |
1186 | 1186 | $this->resultCache[$dn][$attr] = $newItems; |
1187 | 1187 | $dnRead[] = $dn; |
1188 | - } while(($state === self::LRESULT_PROCESSED_SKIP |
|
1188 | + } while (($state === self::LRESULT_PROCESSED_SKIP |
|
1189 | 1189 | || $this->ldap->isResource($entry)) |
1190 | 1190 | && ($dnReadLimit === 0 || $dnReadCount < $dnReadLimit)); |
1191 | 1191 | } |
@@ -1208,11 +1208,11 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | private function determineFeature($objectclasses, $attr, $dbkey, $confkey, $po = false) { |
1210 | 1210 | $cr = $this->getConnection(); |
1211 | - if(!$cr) { |
|
1211 | + if (!$cr) { |
|
1212 | 1212 | throw new \Exception('Could not connect to LDAP'); |
1213 | 1213 | } |
1214 | 1214 | $p = 'objectclass='; |
1215 | - foreach($objectclasses as $key => $value) { |
|
1215 | + foreach ($objectclasses as $key => $value) { |
|
1216 | 1216 | $objectclasses[$key] = $p.$value; |
1217 | 1217 | } |
1218 | 1218 | $maxEntryObjC = ''; |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | $availableFeatures = |
1225 | 1225 | $this->cumulativeSearchOnAttribute($objectclasses, $attr, |
1226 | 1226 | $dig, $maxEntryObjC); |
1227 | - if(is_array($availableFeatures) |
|
1227 | + if (is_array($availableFeatures) |
|
1228 | 1228 | && count($availableFeatures) > 0) { |
1229 | 1229 | natcasesort($availableFeatures); |
1230 | 1230 | //natcasesort keeps indices, but we must get rid of them for proper |
@@ -1235,7 +1235,7 @@ discard block |
||
1235 | 1235 | } |
1236 | 1236 | |
1237 | 1237 | $setFeatures = $this->configuration->$confkey; |
1238 | - if(is_array($setFeatures) && !empty($setFeatures)) { |
|
1238 | + if (is_array($setFeatures) && !empty($setFeatures)) { |
|
1239 | 1239 | //something is already configured? pre-select it. |
1240 | 1240 | $this->result->addChange($dbkey, $setFeatures); |
1241 | 1241 | } else if ($po && $maxEntryObjC !== '') { |
@@ -1257,7 +1257,7 @@ discard block |
||
1257 | 1257 | * LRESULT_PROCESSED_INVALID or LRESULT_PROCESSED_SKIP |
1258 | 1258 | */ |
1259 | 1259 | private function getAttributeValuesFromEntry($result, $attribute, &$known) { |
1260 | - if(!is_array($result) |
|
1260 | + if (!is_array($result) |
|
1261 | 1261 | || !isset($result['count']) |
1262 | 1262 | || !$result['count'] > 0) { |
1263 | 1263 | return self::LRESULT_PROCESSED_INVALID; |
@@ -1266,12 +1266,12 @@ discard block |
||
1266 | 1266 | // strtolower on all keys for proper comparison |
1267 | 1267 | $result = \OCP\Util::mb_array_change_key_case($result); |
1268 | 1268 | $attribute = strtolower($attribute); |
1269 | - if(isset($result[$attribute])) { |
|
1270 | - foreach($result[$attribute] as $key => $val) { |
|
1271 | - if($key === 'count') { |
|
1269 | + if (isset($result[$attribute])) { |
|
1270 | + foreach ($result[$attribute] as $key => $val) { |
|
1271 | + if ($key === 'count') { |
|
1272 | 1272 | continue; |
1273 | 1273 | } |
1274 | - if(!in_array($val, $known)) { |
|
1274 | + if (!in_array($val, $known)) { |
|
1275 | 1275 | $known[] = $val; |
1276 | 1276 | } |
1277 | 1277 | } |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | * @return bool|mixed |
1286 | 1286 | */ |
1287 | 1287 | private function getConnection() { |
1288 | - if(!is_null($this->cr)) { |
|
1288 | + if (!is_null($this->cr)) { |
|
1289 | 1289 | return $this->cr; |
1290 | 1290 | } |
1291 | 1291 | |
@@ -1297,14 +1297,14 @@ discard block |
||
1297 | 1297 | $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); |
1298 | 1298 | $this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0); |
1299 | 1299 | $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); |
1300 | - if($this->configuration->ldapTLS === 1) { |
|
1300 | + if ($this->configuration->ldapTLS === 1) { |
|
1301 | 1301 | $this->ldap->startTls($cr); |
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | $lo = @$this->ldap->bind($cr, |
1305 | 1305 | $this->configuration->ldapAgentName, |
1306 | 1306 | $this->configuration->ldapAgentPassword); |
1307 | - if($lo === true) { |
|
1307 | + if ($lo === true) { |
|
1308 | 1308 | $this->$cr = $cr; |
1309 | 1309 | return $cr; |
1310 | 1310 | } |
@@ -1339,14 +1339,14 @@ discard block |
||
1339 | 1339 | $portSettings = array(); |
1340 | 1340 | |
1341 | 1341 | //In case the port is already provided, we will check this first |
1342 | - if($port > 0) { |
|
1342 | + if ($port > 0) { |
|
1343 | 1343 | $hostInfo = parse_url($host); |
1344 | - if(!(is_array($hostInfo) |
|
1344 | + if (!(is_array($hostInfo) |
|
1345 | 1345 | && isset($hostInfo['scheme']) |
1346 | 1346 | && stripos($hostInfo['scheme'], 'ldaps') !== false)) { |
1347 | 1347 | $portSettings[] = array('port' => $port, 'tls' => true); |
1348 | 1348 | } |
1349 | - $portSettings[] =array('port' => $port, 'tls' => false); |
|
1349 | + $portSettings[] = array('port' => $port, 'tls' => false); |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | //default ports |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | 54 | public function connect($host, $port) { |
55 | - if(strpos($host, '://') === false) { |
|
56 | - $host = 'ldap://' . $host; |
|
55 | + if (strpos($host, '://') === false) { |
|
56 | + $host = 'ldap://'.$host; |
|
57 | 57 | } |
58 | - if(strpos($host, ':', strpos($host, '://') + 1) === false) { |
|
58 | + if (strpos($host, ':', strpos($host, '://') + 1) === false) { |
|
59 | 59 | //ldap_connect ignores port parameter when URLs are passed |
60 | - $host .= ':' . $port; |
|
60 | + $host .= ':'.$port; |
|
61 | 61 | } |
62 | 62 | return $this->invokeLDAPMethod('connect', $host); |
63 | 63 | } |
@@ -267,13 +267,13 @@ discard block |
||
267 | 267 | * @return bool |
268 | 268 | */ |
269 | 269 | protected function isResultFalse($result) { |
270 | - if($result === false) { |
|
270 | + if ($result === false) { |
|
271 | 271 | return true; |
272 | 272 | } |
273 | 273 | |
274 | - if($this->curFunc === 'ldap_search' && is_array($result)) { |
|
274 | + if ($this->curFunc === 'ldap_search' && is_array($result)) { |
|
275 | 275 | foreach ($result as $singleResult) { |
276 | - if($singleResult === false) { |
|
276 | + if ($singleResult === false) { |
|
277 | 277 | return true; |
278 | 278 | } |
279 | 279 | } |
@@ -287,8 +287,8 @@ discard block |
||
287 | 287 | */ |
288 | 288 | protected function invokeLDAPMethod() { |
289 | 289 | $arguments = func_get_args(); |
290 | - $func = 'ldap_' . array_shift($arguments); |
|
291 | - if(function_exists($func)) { |
|
290 | + $func = 'ldap_'.array_shift($arguments); |
|
291 | + if (function_exists($func)) { |
|
292 | 292 | $this->preFunctionCall($func, $arguments); |
293 | 293 | $result = call_user_func_array($func, $arguments); |
294 | 294 | if ($this->isResultFalse($result)) { |
@@ -318,12 +318,12 @@ discard block |
||
318 | 318 | */ |
319 | 319 | private function processLDAPError($resource) { |
320 | 320 | $errorCode = ldap_errno($resource); |
321 | - if($errorCode === 0) { |
|
321 | + if ($errorCode === 0) { |
|
322 | 322 | return; |
323 | 323 | } |
324 | - $errorMsg = ldap_error($resource); |
|
324 | + $errorMsg = ldap_error($resource); |
|
325 | 325 | |
326 | - if($this->curFunc === 'ldap_get_entries' |
|
326 | + if ($this->curFunc === 'ldap_get_entries' |
|
327 | 327 | && $errorCode === -4) { |
328 | 328 | } else if ($errorCode === 32) { |
329 | 329 | //for now |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | throw new \Exception('LDAP Operations error', $errorCode); |
338 | 338 | } else if ($errorCode === 19) { |
339 | 339 | ldap_get_option($this->curArgs[0], LDAP_OPT_ERROR_STRING, $extended_error); |
340 | - throw new ConstraintViolationException(!empty($extended_error)?$extended_error:$errorMsg, $errorCode); |
|
340 | + throw new ConstraintViolationException(!empty($extended_error) ? $extended_error : $errorMsg, $errorCode); |
|
341 | 341 | } else { |
342 | 342 | \OCP\Util::writeLog('user_ldap', |
343 | - 'LDAP error '.$errorMsg.' (' . |
|
343 | + 'LDAP error '.$errorMsg.' ('. |
|
344 | 344 | $errorCode.') after calling '. |
345 | 345 | $this->curFunc, |
346 | 346 | \OCP\Util::DEBUG); |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * Called after an ldap method is run to act on LDAP error if necessary |
352 | 352 | */ |
353 | 353 | private function postFunctionCall() { |
354 | - if($this->isResource($this->curArgs[0])) { |
|
354 | + if ($this->isResource($this->curArgs[0])) { |
|
355 | 355 | $resource = $this->curArgs[0]; |
356 | - } else if( |
|
356 | + } else if ( |
|
357 | 357 | $this->curFunc === 'ldap_search' |
358 | 358 | && is_array($this->curArgs[0]) |
359 | 359 | && $this->isResource($this->curArgs[0][0]) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'user_ldap', 'isDeleted', '1'); |
72 | 72 | |
73 | 73 | $userObjects = array(); |
74 | - foreach($deletedUsers as $user) { |
|
74 | + foreach ($deletedUsers as $user) { |
|
75 | 75 | $userObjects[] = new OfflineUser($user, $this->config, $this->db, $this->mapping); |
76 | 76 | } |
77 | 77 | $this->deletedUsers = $userObjects; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return \OCA\User_LDAP\User\OfflineUser[] |
85 | 85 | */ |
86 | 86 | public function getUsers() { |
87 | - if(is_array($this->deletedUsers)) { |
|
87 | + if (is_array($this->deletedUsers)) { |
|
88 | 88 | return $this->deletedUsers; |
89 | 89 | } |
90 | 90 | return $this->fetchDeletedUsers(); |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | * @return bool |
96 | 96 | */ |
97 | 97 | public function hasUsers() { |
98 | - if($this->deletedUsers === false) { |
|
98 | + if ($this->deletedUsers === false) { |
|
99 | 99 | $this->fetchDeletedUsers(); |
100 | 100 | } |
101 | - if(is_array($this->deletedUsers) && count($this->deletedUsers) > 0) { |
|
101 | + if (is_array($this->deletedUsers) && count($this->deletedUsers) > 0) { |
|
102 | 102 | return true; |
103 | 103 | } |
104 | 104 | return false; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @return null |
131 | 131 | */ |
132 | 132 | private function checkAccess() { |
133 | - if(is_null($this->access)) { |
|
133 | + if (is_null($this->access)) { |
|
134 | 134 | throw new \Exception('LDAP Access instance must be set first'); |
135 | 135 | } |
136 | 136 | } |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | $this->access->getConnection()->ldapUserDisplayName, |
151 | 151 | $this->access->getConnection()->ldapUserDisplayName2, |
152 | 152 | ); |
153 | - foreach($possible as $attr) { |
|
154 | - if(!is_null($attr)) { |
|
153 | + foreach ($possible as $attr) { |
|
154 | + if (!is_null($attr)) { |
|
155 | 155 | $attributes[] = $attr; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | 159 | $homeRule = $this->access->getConnection()->homeFolderNamingRule; |
160 | - if(strpos($homeRule, 'attr:') === 0) { |
|
160 | + if (strpos($homeRule, 'attr:') === 0) { |
|
161 | 161 | $attributes[] = substr($homeRule, strlen('attr:')); |
162 | 162 | } |
163 | 163 | |
164 | - if(!$minimal) { |
|
164 | + if (!$minimal) { |
|
165 | 165 | // attributes that are not really important but may come with big |
166 | 166 | // payload. |
167 | 167 | $attributes = array_merge($attributes, array( |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | */ |
205 | 205 | protected function createInstancyByUserName($id) { |
206 | 206 | //most likely a uid. Check whether it is a deleted user |
207 | - if($this->isDeletedUser($id)) { |
|
207 | + if ($this->isDeletedUser($id)) { |
|
208 | 208 | return $this->getDeletedUser($id); |
209 | 209 | } |
210 | 210 | $dn = $this->access->username2dn($id); |
211 | - if($dn !== false) { |
|
211 | + if ($dn !== false) { |
|
212 | 212 | return $this->createAndCache($dn, $id); |
213 | 213 | } |
214 | 214 | return null; |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function get($id) { |
224 | 224 | $this->checkAccess(); |
225 | - if(isset($this->usersByDN[$id])) { |
|
225 | + if (isset($this->usersByDN[$id])) { |
|
226 | 226 | return $this->usersByDN[$id]; |
227 | - } else if(isset($this->usersByUid[$id])) { |
|
227 | + } else if (isset($this->usersByUid[$id])) { |
|
228 | 228 | return $this->usersByUid[$id]; |
229 | 229 | } |
230 | 230 | |
231 | - if($this->access->stringResemblesDN($id) ) { |
|
231 | + if ($this->access->stringResemblesDN($id)) { |
|
232 | 232 | $uid = $this->access->dn2username($id); |
233 | - if($uid !== false) { |
|
233 | + if ($uid !== false) { |
|
234 | 234 | return $this->createAndCache($id, $uid); |
235 | 235 | } |
236 | 236 | } |