Release 0.3 Copyright ©1994, 1995 by Todd Thomas All Rights Reserved.
MiscUser |
Inherits From: | Object | |
Declared In: | <misckit/MiscUser.h> |
Class Description |
This class represents a single UNIX system user. You can initialize an instance of the class by either user Id (uid) or
username. You can then ask the instance for additional information about the user, like their real name, shell, home
directory, and get a List of groups they belong to. You can also ask the class object to give you a List of all the users on
your system.
Since the underlying Unix functions used to retrieve the user information will climb the domain hierarchy, the information returned by either the class method + allUsers or the instance method - groups is representative of all the information in all the domains (with duplicate entries removed). For instance, if your users were setup like: |
+ allUsers would return : root, me, bill opus.
- members (for instance representing root) would return: wheel, staff and operator.
Instance Variables |
int uid; int gid; char *username; char *realname; char *shell; char *homeDirectory; |
uid | The unique user id representing the user. | |
gid | The user's primary group id. | |
username | The user's username. | |
realname | The user's real name. | |
shell | The user's shell. | |
homeDirectory | The user's home directory. |
Method Types |
+ filterSystemUsers + setFilterSystemUsers: + allUsers + whoAmI - initWithUserId: - groups |
Class Methods |
allUsers |
+ (List | ![]() |
Returns a List of MiscUsers representing all the users on your system. If there are no users (a little unlikely), then nil is
returned. You are responsible for freeing the returned List and it's contents. The underlying Unix functions start looking
for users in the local domain and continue until the root domain, so the returned list includes all those users, with any
duplicate entries removed.
filterSystemUsers |
+ (BOOL)filterSystemUsers |
Returns YES if the class object should filter out system users like nobody, news, uucp, etc, when the class method
allUsers is called. The user root will still be returned in the List. NO is returned if no filtering of users should be done.
The default is NO.
See also: - setFilterSystemUsers:
setFilterSystemUsers: |
+ setFilterSystemUsers:(BOOL)filter |
Set to YES if you would like to filter out system users when asking the MiscUser class for a List of all the system's
users. The default is NO.
See also: - filterSystemUsers
whoAmI |
+ (MiscUser *)whoAmI |
Returns an instance of MiscUser that represents the current user. |
Instance Methods |
free |
- free |
Frees any memory the instance has allocated.
groups |
- (List *)groups |
Returns a List of MiscUserGroups representing the groups the user is a member of. It is your responsibility to free both
the returned List and it's contents. The underlying Unix calls will traverse through all the netinfo domains, so the list
returned will be groups that the user is a member of in at least one of the domains. Duplicate group names are removed.
See also: - primaryGroup
homeDirectory |
- (const char *)homeDirectory |
Returns the home directory of the user. Don't free the string returned.
initWithUserId: |
- initWithUserId:(int)userId |
Initializes an instance of MiscUser to represent the given userId. If the given userId doesn't exist on the system, the
receiver is freed and nil is returned.
See also: - initWithUsername:
initWithUsername: |
- initWithUsername:(const char *)uname |
Initializes an instance of MiscUser to represent the given username. If username does not exist on the system, the
receiver is freed and nil is returned. This method is the designated initializer.
See also: - initWithUserId:
primaryGroup |
- (MiscUserGroup *)primaryGroup |
Returns a MiscUserGroup representing the user's primary group. You are responsible for freeing the returned
MiscUserGroup.
See also: - groups
realname |
- (const char *)realname |
Returns the user's real name. Don't free the returned string.
shell |
- (const char *)shell |
Returns the user's shell. Don't free the returned string.
userId |
- (int)userId |
Returns the user id that the receiver represents.
See also: - username
username |
- (const char *)username |
Returns the username that the receiver respresents.
See also: - userId |