| Description | manuals and libraries | 
Kernel::System::User - user lib
All user functions. E. g. to add and updated user and other functions.
Don't use the constructor directly, use the ObjectManager instead:
    my $UserObject = $Kernel::OM->Get('Kernel::System::User');get user data (UserLogin, UserFirstname, UserLastname, UserEmail, ...)
    my %User = $UserObject->GetUserData(
        UserID => 123,
    );
    or
    my %User = $UserObject->GetUserData(
        User          => 'franz',
        Valid         => 1,       # not required -> 0|1 (default 0)
                                  # returns only data if user is valid
        NoOutOfOffice => 1,       # not required -> 0|1 (default 0)
                                  # returns data without out of office infos
    );to add new users
    my $UserID = $UserObject->UserAdd(
        UserFirstname => 'Huber',
        UserLastname  => 'Manfred',
        UserLogin     => 'mhuber',
        UserPw        => 'some-pass', # not required
        UserEmail     => 'email@example.com',
        UserMobile    => '1234567890', # not required
        ValidID       => 1,
        ChangeUserID  => 123,
    );to update users
    $UserObject->UserUpdate(
        UserID        => 4321,
        UserFirstname => 'Huber',
        UserLastname  => 'Manfred',
        UserLogin     => 'mhuber',
        UserPw        => 'some-pass', # not required
        UserEmail     => 'email@example.com',
        UserMobile    => '1234567890', # not required
        ValidID       => 1,
        ChangeUserID  => 123,
    );to search users
    my %List = $UserObject->UserSearch(
        Search => '*some*', # also 'hans+huber' possible
        Valid  => 1, # not required
    );
    my %List = $UserObject->UserSearch(
        UserLogin => '*some*',
        Limit     => 50,
        Valid     => 1, # not required
    );
    my %List = $UserObject->UserSearch(
        PostMasterSearch => 'email@example.com',
        Valid            => 1, # not required
    );Returns hash of UserID, Login pairs:
    my %List = (
        1 => 'root@locahost',
        4 => 'admin',
        9 => 'joe',
    );For PostMasterSearch, it returns hash of UserID, Email pairs:
    my %List = (
        4 => 'john@example.com',
        9 => 'joe@example.com',
    );to set users passwords
    $UserObject->SetPassword(
        UserLogin => 'some-login',
        PW        => 'some-new-password'
    );user login or id lookup
    my $UserLogin = $UserObject->UserLookup(
        UserID => 1,
        Silent => 1, # optional, don't generate log entry if user was not found
    );
    my $UserID = $UserObject->UserLookup(
        UserLogin => 'some_user_login',
        Silent    => 1, # optional, don't generate log entry if user was not found
    );get user name
    my $Name = $UserObject->UserName(
        User => 'some-login',
    );
    or
    my $Name = $UserObject->UserName(
        UserID => 123,
    );return a hash with all users
    my %List = $UserObject->UserList(
        Type          => 'Short', # Short|Long, default Short
        Valid         => 1,       # default 1
        NoOutOfOffice => 1,       # (optional) default 0
    );generate a random password
    my $Password = $UserObject->GenerateRandomPassword();
    or
    my $Password = $UserObject->GenerateRandomPassword(
        Size => 16,
    );set user preferences
    $UserObject->SetPreferences(
        Key    => 'UserComment',
        Value  => 'some comment',
        UserID => 123,
    );get user preferences
    my %Preferences = $UserObject->GetPreferences(
        UserID => 123,
    );search in user preferences
    my %UserList = $UserObject->SearchPreferences(
        Key   => 'UserEmail',
        Value => 'email@example.com',   # optional, limit to a certain value/pattern
    );generate a random token
    my $Token = $UserObject->TokenGenerate(
        UserID => 123,
    );check password token
    my $Valid = $UserObject->TokenCheck(
        Token  => $Token,
        UserID => 123,
    );return 1 if another user with this login (username) already exists
    $Exist = $UserObject->UserLoginExistsCheck(
        UserLogin => 'Some::UserLogin',
        UserID => 1, # optional
    );This software is part of the OTRS project (https://otrs.org/).
This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (GPL). If you did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.