Base Framework
Classes | Public Member Functions | Static Public Member Functions | List of all members
User Class Reference

User trustee. More...

#include <base/security/User.h>

Inherits Object.

Classes

class  UserException
 User exception. More...
 

Public Member Functions

 User () noexcept
 
 User (unsigned long _id)
 
 User (const void *id)
 
 User (const User &copy) noexcept
 
Useroperator= (const User &assign) noexcept
 
 User (const String &name)
 
bool operator== (const User &compare) const noexcept
 
bool operator!= (const User &compare) const noexcept
 
bool isValid () const noexcept
 
const void * getId () const noexcept
 
unsigned long getIntegralId () const noexcept
 
String getName (bool fallback=true) const
 
String getFullName () const
 
String getHomeFolder () const
 
bool isAdmin () const
 
bool isMemberOf (const Group &group)
 
Array< StringgetGroups ()
 

Static Public Member Functions

static User getCurrentUser ()
 

Detailed Description

User trustee.

A user trustee.

Version
1.2
Examples
testsuite/ls.cpp, and testsuite/Quota.cpp.

Constructor & Destructor Documentation

◆ User() [1/5]

User::User ( )
inlinenoexcept

Initializes user as invalid.

◆ User() [2/5]

User::User ( unsigned long  _id)

Initializes user by id. Raises OutOfDomain if the specified id is not supported by the platform.

◆ User() [3/5]

User::User ( const void *  id)

Initializes user by id. Raises OutOfDomain if the specified id is not supported by the platform.

◆ User() [4/5]

User::User ( const User copy)
noexcept

Initializes user from other user.

◆ User() [5/5]

User::User ( const String name)

Initializes user by name.

Member Function Documentation

◆ getCurrentUser()

static User User::getCurrentUser ( )
static

Returns the user associated with the current process.

Examples
testsuite/Process.cpp, and testsuite/Quota.cpp.

◆ getFullName()

String User::getFullName ( ) const

Returns the full name of the account.

◆ getGroups()

Array<String> User::getGroups ( )

Returns the groups to which the user belongs.

◆ getHomeFolder()

String User::getHomeFolder ( ) const

Returns the path of the home folder.

Examples
testsuite/Quota.cpp.

◆ getId()

const void* User::getId ( ) const
inlinenoexcept

Returns the id of the user.

◆ getIntegralId()

unsigned long User::getIntegralId ( ) const
inlinenoexcept

Returns the integral id of the user.

◆ getName()

String User::getName ( bool  fallback = true) const

Returns the short name of the account.

Parameters
fallbackSpecifies, when true, that a string representation of the id should be returned if the name cannot be resolved. Fall-back is enabled by default.
Examples
testsuite/ls.cpp, testsuite/Process.cpp, and testsuite/Quota.cpp.

◆ isAdmin()

bool User::isAdmin ( ) const

Returns true if the user is an administrator/root.

Examples
testsuite/Process.cpp.

◆ isMemberOf()

bool User::isMemberOf ( const Group group)

Returns true if the user is a member of the specified group.

Returns
false if the group doesn't exist.

◆ isValid()

bool User::isValid ( ) const
inlinenoexcept

Returns true if the user is initialized. This does not mean that the user exists.

◆ operator!=()

bool User::operator!= ( const User compare) const
inlinenoexcept

Returns false if the users are not identical. The method returns false if both users are invalid.

◆ operator=()

User& User::operator= ( const User assign)
noexcept

Assignment of user by user.

◆ operator==()

bool User::operator== ( const User compare) const
noexcept

Returns true if the users are identical. The method returns true if both users are invalid.