Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Apr 17, 2020
1 parent ab550d6 commit 090c59f
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions apps/user_ldap/lib/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function __construct(IConfig $config) {

/**
* returns prefixes for each saved LDAP/AD server configuration.
*
* @param bool $activeConfigurations optional, whether only active configuration shall be
* retrieved, defaults to false
* @return array with a list of the available prefixes
Expand Down Expand Up @@ -97,6 +98,7 @@ public function getServerConfigurationPrefixes($activeConfigurations = false) {
/**
*
* determines the host for every configured connection
*
* @return array an array with configprefix as keys
*
*/
Expand Down Expand Up @@ -149,6 +151,7 @@ private function getServersConfig($value) {

/**
* deletes a given saved LDAP/AD server configuration.
*
* @param string $prefix the configuration prefix of the config to delete
* @return bool true on success, false otherwise
*/
Expand All @@ -166,11 +169,11 @@ public function deleteServerConfiguration($prefix) {
DELETE
FROM `*PREFIX*appconfig`
WHERE `configkey` LIKE ?
'.$saveOtherConfigurations.'
' . $saveOtherConfigurations . '
AND `appid` = \'user_ldap\'
AND `configkey` NOT IN (\'enabled\', \'installed_version\', \'types\', \'bgjUpdateGroupsLastRun\')
');
$delRows = $query->execute([$prefix.'%']);
$delRows = $query->execute([$prefix . '%']);

if ($delRows === null) {
return false;
Expand All @@ -185,8 +188,9 @@ public function deleteServerConfiguration($prefix) {

/**
* checks whether there is one or more disabled LDAP configurations
* @throws \Exception
*
* @return bool
* @throws \Exception
*/
public function haveDisabledConfigurations() {
$all = $this->getServerConfigurationPrefixes(false);
Expand All @@ -201,6 +205,7 @@ public function haveDisabledConfigurations() {

/**
* extracts the domain from a given URL
*
* @param string $url the URL
* @return string|false domain as string on success, false otherwise
*/
Expand Down Expand Up @@ -234,6 +239,7 @@ public function setLDAPProvider() {

/**
* sanitizes a DN received from the LDAP server
*
* @param array $dn the DN in question
* @return array|string the sanitized DN
*/
Expand All @@ -247,12 +253,12 @@ public function sanitizeDN($dn) {
return $result;
}

if(!is_string($dn)) {
if (!is_string($dn)) {
throw new \LogicException('String expected ' . \gettype($dn) . ' given');
}

if (($sanitizedDn = $this->sanitizeDnCache->get($dn)) !== null) {
return $sanitizedDn;
return $sanitizedDn;
}

//OID sometimes gives back DNs with whitespace after the comma
Expand All @@ -274,9 +280,9 @@ public function sanitizeDN($dn) {
'\;' => '\5c3B',
'\"' => '\5c22',
'\#' => '\5c23',
'(' => '\28',
')' => '\29',
'*' => '\2A',
'(' => '\28',
')' => '\29',
'*' => '\2A',
];
$sanitizedDn = str_replace(array_keys($replacements), array_values($replacements), $sanitizedDn);
$this->sanitizeDnCache->set($dn, $sanitizedDn);
Expand All @@ -286,6 +292,7 @@ public function sanitizeDN($dn) {

/**
* converts a stored DN so it can be used as base parameter for LDAP queries, internally we store them for usage in LDAP filters
*
* @param string $dn the DN
* @return string
*/
Expand Down Expand Up @@ -316,7 +323,7 @@ public static function loginName2UserName($param) {
$userSession = \OC::$server->getUserSession();
$userPluginManager = \OC::$server->query('LDAPUserPluginManager');

$userBackend = new User_Proxy(
$userBackend = new User_Proxy(
$configPrefixes, $ldapWrapper, $ocConfig, $notificationManager, $userSession, $userPluginManager
);
$uid = $userBackend->loginName2UserName($param['uid']);
Expand Down

0 comments on commit 090c59f

Please sign in to comment.