NAME
WE::DB::ComplexUser - Webeditor user database.
SYNOPSIS
use WE::DB::ComplexUser;
my $udb = WE::DB::ComplexUser->new($root_db, $user_db_file, %args);
DESCRIPTION
Object for administration of webeditor-users. You can add, delete, identify, modify users. This is an MLDBM implementation of the WE::DB::User module.
NOTE Due to histerical reasons, the returned value of most methods is not a boolean value as one would expect. Rather the ERROR_*
constants should be used instead, see "CONSTANTS".
User objects
The user elements are objects of the class WE::UserObj
(this may be changed by overriding the UserObjClass method) objects with the following members:
- Username
-
The short name for the user.
- Password
-
The (probably crypted) password.
- Realname
-
The full name of the user.
- Groups
-
An array reference to the groups of this user.
- Roles
-
An array reference to the roles of this user.
-
The email address of the user.
- Homedirectory
-
The home directory of the user. This may be the classical UNIX home directory, or the default starting point in the web.editor tree hierarchy.
- Shell
-
The shell of the user. This may be the classical UNIX shell.
- Language
-
The preferred language of the user. This should be a string or an array of languages.
- AuthType
-
The authentication type of the user. The default (undef, empty string or "userdb") means to use the Password entry of the ComplexUser database. For other values an external module is consulted, which is named
WE::DB::ComplexUser::Authauthtype
. See WE::DB::ComplexUser::AuthPOP3 and WE::DB::ComplexUser::AuthUnix. - Id
-
An automatically increased identifier, which is set when adding the object to the database. Note that the Username is used to identify an user object, not the Id.
Group objects
There's also elements of the class WE::GroupObj
for group objects. The group objects have the following members:
- Groupname
-
The full name of the group
- Description
-
A description of the group's purpose
- Id
-
An Id, see the WE::UserObj description for Id.
Note that accessing WE::GroupObj
objects is not very efficient, especially for databases with a large group number.
CONSTRUCTOR
my $udb = WE::DB::ComplexUser->new($root_db, $user_db_file, %args);
The $root_db argument is optional and should be either undef
or a WE::DB object.
The $user_db_file is the pathname to the database file.
Remaining arguments may be:
- -crypt => 'crypt'
-
Use crypt for crypting password (default).
- -crypt => 'none'
-
Do not crypt passwords.
METHODS
- $udb->add_user($username,$password,$fullrealname)
-
This is deprecated, use "$udb->add_user_object" instead.
Add a user with the specified $username, I$<password> and $fullrealname. Return ERROR_OK if creation of user was successful. Die on errors (e.g. if invalid characters or an invalid username is used).
- $udb->add_user_object($o)
-
Add a user with the specified
WE::UserObj
object. Return ERROR_OK if creation of user by object was successful. See "$udb->add_user" for exceptions. - $udb->get_fullname($username)
-
Return string with full reallife name.
- $udb->identify($username,$entered_password)
-
Identify the given $username with the $entered_password and return 1 (ERROR_OK), if the authentication was successful.
- $udb->identify_object($username,$entered_password)
-
Identify the given $username with the $entered_password and return the user object, if the authentication was successful.
- $udb->user_exists($username)
-
Return 1 if the specified $username exists.
- $udb->delete_user($username)
-
Delete the specified $username. Return ERROR_OK if successful.
- $udb->is_in_group($username,$group)
-
Return 1 if $username is in the named $group.
- $udb->get_groups($username)
-
Return an array of the $username's groups.
Return 1 if $username is in the named $group.
- $udb->add_group($username,$group)
-
Add the given $group to the $username. Return ERROR_OK if adding group to user was successful. Note: there's no check if the named group really exists. Die if invalid characters are used.
- $udb->set_groups($username, @groups)
-
Replace $username's group list with @groups. Die if invalid characters are used.
- $udb->delete_group($username,$group)
-
Delete the given $group from the $username's group list. Return ERROR_OK if deleting group was successful.
- $udb->get_users_of_group($group)
-
Return an array of usernames belonging to this $group.
- $udb->get_all_users()
-
Return an array of all existing users.
- $udb->get_all_groups()
-
Return an array of all existing groups.
- $udb->get_user_object($user)
-
Return a
WE::UserObj
object for the given $user, orundef
. - $udb->set_user_object($o)
- $udb->set_user_object($user, $o)
-
Replace the user $user with the
WE::UserObj
object $o. In the first form, the username is taken from $o. Return the user object or die on errors. - $udb->delete_all_groups
-
Delete all existing groups (globally and for each user).
- $udb->delete_group_definition($group)
-
Delete the named $group (globally and for each user).
- $udb->add_group_definition($group, %args)
-
Add a new $group globally. %args is unused for now.
- $udb->get_group_definition($group)
-
Return the $group definition as a hash reference or
undef
. - $udb->set_group_definition($group, $o)
-
Replace the group definition $o for the given $group.
- $udb->_predefined_groups
-
Return an array with predefined groups. This method may be overridden by a sub class.
- $udb->set_password($userobj, $password)
-
Set the $password in the given $userobj. Depending on the crypt mode of the user database, this will be encrypted or unencrypted. Does not save the $userobj into the database. Use this method instead of setting the Password member in the $userobj directly.
- $udb->ErrorType([$error_type])
-
Set how errors are handled:
- ERROR_TYPE_DIE
-
If errors are encountered, the method will die. This is the default.
- ERROR_TYPE_RETURN
-
If errors are encountered, the method will return with an error code. The error message can be fetched by
$udb->ErrorMsg
.
Without argument return the current value.
CONSTANTS
These error constants may be used, either fully qualified or as static methods:
ERROR_NOT_ACCEPTED
ERROR_OK
ERROR_INVALID_CHAR
ERROR_GROUP_EXISTS
ERROR_USER_EXISTS
HISTORY
An incompatible change occurred around 2005-02-16 (between version 2.19 and 2.20): adding an existing user used to return "0", but now it returns ERROR_USER_EXISTS
.
AUTHORS
Olaf Mätzner - maetzner@onlineoffice.de, Slaven Rezic - slaven@rezic.de
SEE ALSO
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1019:
Non-ASCII character seen before =encoding in 'Mätzner'. Assuming CP1252