Browse Source

Merge pull request #584 from wardragon/ldap_access_userExists_fix

Really fix OCP\Share::shareItem with LDAP users
remotes/origin/stable5
blizzz 14 years ago
parent
commit
680ff3a51b
  1. 6
      apps/user_ldap/lib/access.php
  2. 6
      lib/public/user.php
  3. 7
      lib/user.php

6
apps/user_ldap/lib/access.php

@ -288,8 +288,8 @@ abstract class Access {
} }
$ldapname = $this->sanitizeUsername($ldapname); $ldapname = $this->sanitizeUsername($ldapname);
//a new user/group! Then let's try to add it. We're shooting into the blue with the user/group name, assuming that in most cases there will not be a conflict. Otherwise an error will occur and we will continue with our second shot.
if(($isUser && !\OCP\User::userExists($ldapname)) || (!$isUser && !\OC_Group::groupExists($ldapname))) {
//a new user/group! Add it only if it doesn't conflict with other backend's users or existing groups
if(($isUser && !\OCP\User::userExists($ldapname, 'OCA\\user_ldap\\USER_LDAP')) || (!$isUser && !\OC_Group::groupExists($ldapname))) {
if($this->mapComponent($dn, $ldapname, $isUser)) { if($this->mapComponent($dn, $ldapname, $isUser)) {
return $ldapname; return $ldapname;
} }
@ -881,4 +881,4 @@ abstract class Access {
return $pagedSearchOK; return $pagedSearchOK;
} }
}
}

6
lib/public/user.php

@ -65,12 +65,12 @@ class User {
/** /**
* @brief check if a user exists * @brief check if a user exists
* @param string $uid the username * @param string $uid the username
* @param string $excludingBackend (default none)
* @return boolean * @return boolean
*/ */
public static function userExists( $uid ) {
return \OC_USER::userExists( $uid );
public static function userExists( $uid, $excludingBackend = null ) {
return \OC_USER::userExists( $uid, $excludingBackend );
} }
/** /**
* @brief Loggs the user out including all the session data * @brief Loggs the user out including all the session data
* @returns true * @returns true

7
lib/user.php

@ -414,10 +414,15 @@ class OC_User {
/** /**
* @brief check if a user exists * @brief check if a user exists
* @param string $uid the username * @param string $uid the username
* @param string $excludingBackend (default none)
* @return boolean * @return boolean
*/ */
public static function userExists($uid) {
public static function userExists($uid, $excludingBackend=null) {
foreach(self::$_usedBackends as $backend) { foreach(self::$_usedBackends as $backend) {
if (!is_null($excludingBackend) && !strcmp(get_class($backend),$excludingBackend)) {
OC_Log::write('OC_User', $excludingBackend . 'excluded from user existance check.', OC_Log::DEBUG);
continue;
}
$result=$backend->userExists($uid); $result=$backend->userExists($uid);
if($result===true) { if($result===true) {
return true; return true;

Loading…
Cancel
Save