OC_User

class OC_User
This class provides wrapper methods for user management. Multiple backends are
supported. User management operations are delegated to the configured backend for
execution.
Note that &run is deprecated and won’t work anymore.

Hooks provided:
pre_createUser(&run, uid, password)
post_createUser(uid, password)
pre_deleteUser(&run, uid)
post_deleteUser(uid)
pre_setPassword(&run, uid, password, recoveryPassword)
post_setPassword(uid, password, recoveryPassword)
pre_login(&run, uid, password)
post_login(uid)
logout()
Source:lib/private/legacy/OC_User.php#59

Properties

Methods

public static OC_User::useBackend($backend=database)
Adds the backend to the list of used backends
Source:

lib/private/legacy/OC_User.php#76

Parameters:
  • $backend (string | \OCP\UserInterface) default: database The backend to use for user management
Returns:

bool Set the User Authentication Module

public static OC_User::clearBackends()
remove all used backends
Source:lib/private/legacy/OC_User.php#113
public static OC_User::setupBackends()
setup the configured backends in config.php
Source:lib/private/legacy/OC_User.php#122
public static OC_User::loginWithApache($backend)
Try to login a user, assuming authentication
has already happened (e.g. via Single Sign On).
Log in a user and regenerate a new session.
Source:

lib/private/legacy/OC_User.php#162

Parameters:
Returns:

bool

public static OC_User::handleApacheAuth()
Verify with Apache whether user is authenticated.
Source:lib/private/legacy/OC_User.php#205
Returns:bool | null true: authenticated false: not authenticated null: not handled / no backend available
public static OC_User::setUserId($uid)
Sets user id for session and triggers emit
Source:

lib/private/legacy/OC_User.php#226

Parameters:
  • $uid (string)
public static OC_User::isLoggedIn()
Check if the user is logged in, considers also the HTTP basic credentials
Source:lib/private/legacy/OC_User.php#242
Deprecated:use \OC::$server->getUserSession()->isLoggedIn()
Returns:bool
public static OC_User::setIncognitoMode($status)
set incognito mode, e.g. if a user wants to open a public link
Source:

lib/private/legacy/OC_User.php#251

Parameters:
  • $status (bool)
public static OC_User::isIncognitoMode()
get incognito mode status
Source:lib/private/legacy/OC_User.php#260
Returns:bool
public static OC_User::getLogoutUrl($urlGenerator)
Returns the current logout URL valid for the currently logged-in user
Source:

lib/private/legacy/OC_User.php#270

Parameters:
Returns:

string

public static OC_User::isAdminUser($uid)
Check if the user is an admin user
Source:

lib/private/legacy/OC_User.php#296

Parameters:
  • $uid (string) uid of the admin
Returns:

bool

public static OC_User::getUser()
get the user id of the user currently logged in.
Source:lib/private/legacy/OC_User.php#311
Returns:string | bool uid or false
public static OC_User::getDisplayName($uid=\null)
get the display name of the user currently logged in.
Source:

lib/private/legacy/OC_User.php#328

Parameters:
  • $uid (string)
Returns:

string | bool uid or false

Deprecated:

8.1.0 fetch \OCP\IUser (has getDisplayName()) by using method get() of \OCP\IUserManager - \OC::$server->getUserManager()

public static OC_User::setPassword($uid, $password, $recoveryPassword=\null)
Set password
Source:

lib/private/legacy/OC_User.php#356

Parameters:
  • $uid (string) The username
  • $password (string) The new password
  • $recoveryPassword (string) for the encryption app to reset encryption keys
Returns:

bool Change the password of a user

public static OC_User::getHome($uid)
Source:

lib/private/legacy/OC_User.php#372

Parameters:
  • $uid (string) The username
Returns:

string returns the path to the users home directory

Deprecated:

Use \OC::$server->getUserManager->getHome()

public static OC_User::getDisplayNames($search="", $limit=\null, $offset=\null)
Get a list of all users display name
Source:

lib/private/legacy/OC_User.php#392

Parameters:
  • $search (string)
  • $limit (int)
  • $offset (int)
Returns:

array associative array with all display names (value) and corresponding uids (key)

Get a list of all display names and user ids.

Deprecated:

Use \OC::$server->getUserManager->searchDisplayName($search, $limit, $offset) instead.