Rudiments
Public Member Functions | Static Public Member Functions | List of all members
userentry Class Reference

Inherits object.

Public Member Functions

 userentry ()
 
 ~userentry ()
 
bool open (const char *username)
 
bool open (uid_t userid)
 
const char * getName ()
 
const char * getPassword ()
 
uid_t getUserId ()
 
const char * getSidString ()
 
const void * getSid ()
 
uint64_t getSidSize ()
 
gid_t getPrimaryGroupId ()
 
const char * getRealName ()
 
const char * getHomeDirectory ()
 
const char * getShell ()
 
const char * getEncryptedPassword ()
 
long getLastChangeDate ()
 
int32_t getDaysBeforeChangeAllowed ()
 
int32_t getDaysBeforeChangeRequired ()
 
int32_t getDaysBeforeExpirationWarning ()
 
int32_t getDaysOfInactivityAllowed ()
 
int32_t getExpirationDate ()
 
int32_t getFlag ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Static Public Member Functions

static char * getName (uid_t userid)
 
static uid_t getUserId (const char *username)
 
static char * getSidString (const char *username)
 
static bool supportsFormalSid ()
 
static bool getNeedsMutex ()
 
static void setMutex (threadmutex *mtx)
 

Detailed Description

The userentry class provides methods for retrieving information about users.

Constructor & Destructor Documentation

◆ userentry()

userentry::userentry ( )

Creates an instance of the userentry class.

◆ ~userentry()

userentry::~userentry ( )

Deletes this instance of the userentry class.

Member Function Documentation

◆ getDaysBeforeChangeAllowed()

int32_t userentry::getDaysBeforeChangeAllowed ( )

Returns the number of days before the password for the user may be changed.

◆ getDaysBeforeChangeRequired()

int32_t userentry::getDaysBeforeChangeRequired ( )

Returns the number of days before the password for the user is required to be changed.

◆ getDaysBeforeExpirationWarning()

int32_t userentry::getDaysBeforeExpirationWarning ( )

Returns the number of days before a warning that the password for the user will expire should be displayed.

◆ getDaysOfInactivityAllowed()

int32_t userentry::getDaysOfInactivityAllowed ( )

Returns the number of days of inactivity that are allowed for the user before the password will expire.

◆ getEncryptedPassword()

const char* userentry::getEncryptedPassword ( )

Returns the encrypted password of this user.

◆ getExpirationDate()

int32_t userentry::getExpirationDate ( )

Returns the expiration date of the user. The date is returned as the number of seconds since 1970.

◆ getFlag()

int32_t userentry::getFlag ( )

Returns the system-specific set of flags for the user.

◆ getHomeDirectory()

const char* userentry::getHomeDirectory ( )

Returns the home directory of this user.

◆ getLastChangeDate()

long userentry::getLastChangeDate ( )

Returns the last time that the password for the user was changed. The time is given as the number of seconds since 1970.

◆ getName() [1/2]

const char* userentry::getName ( )

Returns the name of this user.

◆ getName() [2/2]

static char* userentry::getName ( uid_t  userid)
static

Convenience method. Returns the name of the user specified by "userid".

Note that the return value is allocated internally and returned. The calling program must free the buffer.

Returns NULL if an error occurred or if "userid" is invalid.

◆ getNeedsMutex()

static bool userentry::getNeedsMutex ( )
static

Returns true if this class needs a mutex to operate safely in a threaded environment and false otherwise.

◆ getPassword()

const char* userentry::getPassword ( )

Returns the encrypted password of this user.

◆ getPrimaryGroupId()

gid_t userentry::getPrimaryGroupId ( )

Returns the primary group id of this user.

◆ getRealName()

const char* userentry::getRealName ( )

Returns the real name of this user.

◆ getShell()

const char* userentry::getShell ( )

Returns the shell of this user.

◆ getSid()

const void* userentry::getSid ( )

Returns a binary representation of the SID (security id) of this user.

Note: On platforms (like non-Windows platforms) where the supportsFormalSid method returns false, the value returned is just a string representation of the number returned by getUserId().

◆ getSidSize()

uint64_t userentry::getSidSize ( )

Returns the size of the binary representation of the SID (security id) of this user, returned by getSid().

◆ getSidString() [1/2]

const char* userentry::getSidString ( )

Returns a string representation of the SID (security id) of this user.

Note: On platforms (like non-Windows platforms) where the supportsFormalSid method returns false, the value returned is just a string representation of the number returned by getUserId().

◆ getSidString() [2/2]

static char* userentry::getSidString ( const char *  username)
static

Convenience method. Returns a string representation of the SID (security id) of the user specified by "username". See non-static version of this method for more information.

Note that the return value is allocated internally and returned. The calling program must free the buffer.

Returns NULL if an error occurred or if "username" is invalid.

◆ getUserId() [1/2]

uid_t userentry::getUserId ( )

Returns the id of this user.

Note: On platforms (like Windows) where the supportsFormalSid method returns true, users don't hav simple numeric ids. On those platforms, the value returned by this method is simply an index into an internal structure that methods of other rudiments classes know how to access and ultimately translate to a user. It should not be passed in to functions or methods of other libraries that don't ultimately use rudiments methods.

◆ getUserId() [2/2]

static uid_t userentry::getUserId ( const char *  username)
static

Convenience method. Returns the id of the user specified by "username". See non-static version of this method for more information.

Returns -1 if an error occurred or if "username" is invalid.

◆ open() [1/2]

bool userentry::open ( const char *  username)

Opens a user entry by name. Returns true on success and false on failure.

◆ open() [2/2]

bool userentry::open ( uid_t  userid)

Opens a user entry by user id. Returns true on success and false on failure.

◆ setMutex()

static void userentry::setMutex ( threadmutex mtx)
static

Allows you to supply a mutex is the class needs it (see getNeedsMutex()). If your application is not multithreaded, then there is no need to supply a mutex.

◆ supportsFormalSid()

static bool userentry::supportsFormalSid ( )
static

Returns true if the platform supports a formal user SID (security id) and false if not.

Windows and windows-like platforms do. Unix and unix-like platforms (including Mac OS X) do not.