userentry Class Reference

## Public Member Functions

| userentry ()
| userentry (const userentry &u)
userentry & | operator= (const userentry &u)
| ~userentry ()
bool | initialize (const char *username)
bool | initialize (uid_t userid)
const char * | getName () const
const char * | getPassword () const
uid_t | getUserId () const
const char * | getSidString () const
const void * | getSid () const
uint64_t | getSidSize () const
gid_t | getPrimaryGroupId () const
const char * | getRealName () const
const char * | getHomeDirectory () const
const char * | getShell () const
const char * | getEncryptedPassword () const
long | getLastChangeDate () const
int32_t | getDaysBeforeChangeAllowed () const
int32_t | getDaysBeforeChangeRequired () const
int32_t | getDaysBeforeExpirationWarning () const
int32_t | getDaysOfInactivityAllowed () const
int32_t | getExpirationDate () const
int32_t | getFlag () const

## 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 | platformSupportsFormalSid ()
static bool | needsMutex ()
static void | setMutex (threadmutex *mtx)

## Detailed Description

The userentry class provides methods for retrieving information about users.

## Constructor & Destructor Documentation

## userentry() [1/2]

userentry::userentry | ( |  | ) |

Creates an instance of the userentry class.

## userentry() [2/2]

userentry::userentry | ( | const userentry & | u | ) |

Creates an instance of the userentry class. that is a copy of "u".

## ~userentry()

userentry::~userentry | ( |  | ) |

Deletes this instance of the userentry class.

## Member Function Documentation

## getDaysBeforeChangeAllowed()

int32_t userentry::getDaysBeforeChangeAllowed | ( |  | ) | const

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

## getDaysBeforeChangeRequired()

int32_t userentry::getDaysBeforeChangeRequired | ( |  | ) | const

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

## getDaysBeforeExpirationWarning()

int32_t userentry::getDaysBeforeExpirationWarning | ( |  | ) | const

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

## getDaysOfInactivityAllowed()

int32_t userentry::getDaysOfInactivityAllowed | ( |  | ) | const

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

## getEncryptedPassword()

const char* userentry::getEncryptedPassword | ( |  | ) | const

Returns the encrypted password of this user.

## getExpirationDate()

int32_t userentry::getExpirationDate | ( |  | ) | const

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

## getFlag()

int32_t userentry::getFlag | ( |  | ) | const

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

## getHomeDirectory()

const char* userentry::getHomeDirectory | ( |  | ) | const

Returns the home directory of this user.

## getLastChangeDate()

long userentry::getLastChangeDate | ( |  | ) | const

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 | ( |  | ) | const

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.

## getPassword()

const char* userentry::getPassword | ( |  | ) | const

Returns the encrypted password of this user.

## getPrimaryGroupId()

gid_t userentry::getPrimaryGroupId | ( |  | ) | const

Returns the primary group id of this user.

## getRealName()

const char* userentry::getRealName | ( |  | ) | const

Returns the real name of this user.

## getShell()

const char* userentry::getShell | ( |  | ) | const

Returns the shell of this user.

## getSid()

const void* userentry::getSid | ( |  | ) | const

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

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

## getSidSize()

uint64_t userentry::getSidSize | ( |  | ) | const

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 | ( |  | ) | const

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

Note: On platforms (like non-Windows platforms) where the platformSupportsFormalSid 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 | ( |  | ) | const

Returns the id of this user.

Note: On platforms (like Windows) where the platformSupportsFormalSid method returns true, users don't have 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.

## initialize() [1/2]

bool userentry::initialize | ( | const char * | username | ) |

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

## initialize() [2/2]

bool userentry::initialize | ( | uid_t | userid | ) |

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

## needsMutex()

static bool userentry::needsMutex | ( |  | ) |

static

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

## operator=()

userentry& userentry::operator= | ( | const userentry & | u | ) |

Makes this instance of the userentry class identical to "u".

## platformSupportsFormalSid()

static bool userentry::platformSupportsFormalSid | ( |  | ) |

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.

## setMutex()

static void userentry::setMutex | ( | threadmutex * | mtx | ) |

static

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