|
|
@@ -527,6 +527,7 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
* @param bool|null $newlyMapped |
|
|
|
* @param array|null $record |
|
|
|
* @return false|string with with the name to use in Nextcloud |
|
|
|
* @throws \Exception |
|
|
|
*/ |
|
|
|
public function dn2ocname($fdn, $ldapName = null, $isUser = true, &$newlyMapped = null, array $record = null) { |
|
|
|
$newlyMapped = false; |
|
|
@@ -586,7 +587,7 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
// outside of core user management will still cache the user as non-existing. |
|
|
|
$originalTTL = $this->connection->ldapCacheTTL; |
|
|
|
$this->connection->setConfiguration(array('ldapCacheTTL' => 0)); |
|
|
|
if(($isUser && !\OCP\User::userExists($intName)) |
|
|
|
if(($isUser && $intName !== '' && !\OCP\User::userExists($intName)) |
|
|
|
|| (!$isUser && !\OC::$server->getGroupManager()->groupExists($intName))) { |
|
|
|
if($mapper->map($fdn, $intName, $uuid)) { |
|
|
|
$this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); |
|
|
@@ -830,7 +831,9 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
$recordsToUpdate = array_filter($ldapRecords, function($record) use ($isBackgroundJobModeAjax) { |
|
|
|
$newlyMapped = false; |
|
|
|
$uid = $this->dn2ocname($record['dn'][0], null, true, $newlyMapped, $record); |
|
|
|
$this->cacheUserExists($uid); |
|
|
|
if(is_string($uid)) { |
|
|
|
$this->cacheUserExists($uid); |
|
|
|
} |
|
|
|
return ($uid !== false) && ($newlyMapped || $isBackgroundJobModeAjax); |
|
|
|
}); |
|
|
|
} |
|
|
@@ -1022,7 +1025,7 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
* |
|
|
|
* @param $filter |
|
|
|
* @param $base |
|
|
|
* @param null $attr |
|
|
|
* @param string[]|string|null $attr |
|
|
|
* @param int $limit optional, maximum results to be counted |
|
|
|
* @param int $offset optional, a starting point |
|
|
|
* @return array|false array with the search result as first value and pagedSearchOK as |
|
|
@@ -1106,6 +1109,7 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
|
|
|
|
/** |
|
|
|
* executes an LDAP search, but counts the results only |
|
|
|
* |
|
|
|
* @param string $filter the LDAP filter for the search |
|
|
|
* @param array $base an array containing the LDAP subtree(s) that shall be searched |
|
|
|
* @param string|string[] $attr optional, array, one or more attributes that shall be |
|
|
@@ -1115,7 +1119,7 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
* @param bool $skipHandling indicates whether the pages search operation is |
|
|
|
* completed |
|
|
|
* @return int|false Integer or false if the search could not be initialized |
|
|
|
* |
|
|
|
* @throws ServerNotAvailableException |
|
|
|
*/ |
|
|
|
private function count($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) { |
|
|
|
\OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), \OCP\Util::DEBUG); |
|
|
@@ -1130,8 +1134,7 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
$this->connection->getConnectionResource(); |
|
|
|
|
|
|
|
do { |
|
|
|
$search = $this->executeSearch($filter, $base, $attr, |
|
|
|
$limitPerPage, $offset); |
|
|
|
$search = $this->executeSearch($filter, $base, $attr, $limitPerPage, $offset); |
|
|
|
if($search === false) { |
|
|
|
return $counter > 0 ? $counter : false; |
|
|
|
} |
|
|
@@ -1286,7 +1289,7 @@ class Access extends LDAPUtility implements IUserTools { |
|
|
|
*/ |
|
|
|
public function sanitizeUsername($name) { |
|
|
|
if($this->connection->ldapIgnoreNamingRules) { |
|
|
|
return $name; |
|
|
|
return trim($name); |
|
|
|
} |
|
|
|
|
|
|
|
// Transliteration |