passwdentry Class Reference

## Public Member Functions

| passwdentry ()
| passwdentry (const passwdentry &p)
passwdentry & | operator= (const passwdentry &p)
| ~passwdentry ()
bool | initialize (const char *username)
bool | initialize (uid_t userid)
const char * | getName () const
const char * | getPassword () const
uid_t | getUserId () const
const char * | getSid () const
gid_t | getPrimaryGroupId () const
const char * | getRealName () const
const char * | getHomeDirectory () const
const char * | getShell () const

## Static Public Member Functions

static char * | getName (uid_t userid)
static uid_t | getUserId (const char *username)
static char * | getSid (const char *username)
static bool | platformSupportsFormalSid ()
static bool | needsMutex ()
static void | setMutex (threadmutex *mtx)

## Detailed Description

The passwdentry class provides methods for retrieving information about users.

## Constructor & Destructor Documentation

passwdentry::passwdentry | ( |  | ) |

Creates an instance of the passwdentry class.

passwdentry::passwdentry | ( | const passwdentry & | p | ) |

Creates an instance of the passwdentry class. that is a copy of "p".

passwdentry::~passwdentry | ( |  | ) |

Deletes this instance of the passwdentry class.

## Member Function Documentation

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

Returns the home directory of this user.

const char* passwdentry::getName | ( |  | ) | const

Returns the name of this user.

static char* passwdentry::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.

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

Returns the encrypted password of this user.

gid_t passwdentry::getPrimaryGroupId | ( |  | ) | const

Returns the primary group id of this user.

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

Returns the real name of this user.

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

Returns the shell of this user.

const char* passwdentry::getSid | ( |  | ) | 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().

static char* passwdentry::getSid | ( | const char * | username | ) |

static

Convenience method. Returns the SID 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.

uid_t passwdentry::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.

static uid_t passwdentry::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.

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

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

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

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

static bool passwdentry::needsMutex | ( |  | ) |

static

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

passwdentry& passwdentry::operator= | ( | const passwdentry & | p | ) |

Makes this instance of the passwdentry class identical to "p".

static bool passwdentry::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.

static void passwdentry::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.