Database

class OC\User\Database
Class for user management in a SQL Database (e.g. MySQL, SQLite)
Source:lib/private/User/Database.php#80
Parent:OCP\User\Backend\ABackend
Implements:OCP\User\Backend\ICreateUserBackend OCP\User\Backend\ISetPasswordBackend OCP\User\Backend\ISetDisplayNameBackend OCP\User\Backend\IGetDisplayNameBackend OCP\User\Backend\ICheckPasswordBackend OCP\User\Backend\IGetHomeBackend OCP\User\Backend\ICountUsersBackend OCP\User\Backend\ISearchKnownUsersBackend OCP\User\Backend\IGetRealUIDBackend

Properties

Methods

public OC\User\Database::__construct($eventDispatcher=null, $table=users)
\OC\User\Database constructor.
Source:

lib/private/User/Database.php#108

Parameters:
public OC\User\Database::createUser($uid, $password)
Create a new user
Source:

lib/private/User/Database.php#133

Parameters:
  • $uid (string) The username of the user to create
  • $password (string) The password of the new user
Returns:

bool Creates a new user. Basic checking of username is done in OC_User itself, not in its subclasses.

public OC\User\Database::deleteUser($uid)
delete a user
Source:

lib/private/User/Database.php#166

Parameters:
  • $uid (string) The username of the user to delete
Returns:

bool Deletes a user

public OC\User\Database::setPassword($uid, $password)
Set password
Source:

lib/private/User/Database.php#201

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

bool Change the password of a user

public OC\User\Database::setDisplayName($uid, $displayName)
Set display name
Source:

lib/private/User/Database.php#225

Parameters:
  • $uid (string) The username
  • $displayName (string) The new display name
Returns:

bool Change the display name of a user

public OC\User\Database::getDisplayName($uid)
get display name of the user
Source:

lib/private/User/Database.php#249

Parameters:
  • $uid (string) user ID of the user
Returns:

string display name

public OC\User\Database::getDisplayNames($search="", $limit=null, $offset=null)
Get a list of all display names and user ids.
Source:

lib/private/User/Database.php#263

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

array an array of all displayNames (value) and the corresponding uids (key)

public OC\User\Database::searchKnownUsersByDisplayName($searcher, $pattern, $limit=null, $offset=null)
Source:

lib/private/User/Database.php#303

Parameters:
  • $searcher (string)
  • $pattern (string)
  • $limit (int | null)
  • $offset (int | null)
Returns:

array

Since:

21.0.1

public OC\User\Database::checkPassword($loginName, $password)
Check if the password is correct
Source:

lib/private/User/Database.php#345

Parameters:
  • $loginName (string) The loginname
  • $password (string) The password
Returns:

string Check if the password is correct without logging in the user returns the user id or false

public OC\User\Database::getUsers($search="", $limit=null, $offset=null)
Get a list of all users
Source:

lib/private/User/Database.php#425

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

string[] an array of all uids

public OC\User\Database::userExists($uid)
check if a user exists
Source:

lib/private/User/Database.php#442

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

bool

public OC\User\Database::getHome($uid)
get the user’s home directory
Source:

lib/private/User/Database.php#453

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

string | bool

public OC\User\Database::hasUserListings()
Source:lib/private/User/Database.php#464
Returns:bool
public OC\User\Database::countUsers()
counts the users in the database
Source:lib/private/User/Database.php#473
Returns:int | bool
public OC\User\Database::loginName2UserName($loginName)
returns the username for the given login name in the correct casing
Source:

lib/private/User/Database.php#490

Parameters:
  • $loginName (string)
Returns:

string | bool

public OC\User\Database::getBackendName()
Backend name to be shown in user management
Source:lib/private/User/Database.php#503
Returns:string the name of the backend to be shown
public static OC\User\Database::preLoginNameUsedAsUserName($param)
Source:lib/private/User/Database.php#507
public OC\User\Database::getRealUID($uid)
Source:lib/private/User/Database.php#525