« Back to Product

Documentation

IPS_SetUserPassword

 bool IPS_SetUserPassword (string $User, string $Password) 

Parameters

User

Name of the user (case-sensitive)

Password

New password of the user

Returns

If the function succeeds, it returns TRUE, otherwise FALSE.

Description

The function sets the password of the user User. The password is not stored in plain text but only as a salted hash (PBKDF2-HMAC-SHA256) and therefore cannot be read back.

The password is only used for local accounts (user type 0, USER_TYPE_LOCAL). As long as no password has been set for a local account, logging in is not possible. LDAP users (user type 1, USER_TYPE_LDAP) log in via the LDAP server with their BindDN instead (see IPS_SetUserBindDN); the password set here is not evaluated for them.

Warning

This function is only available for licenses that include the RBAC feature (Permission Control). Otherwise it fails with "This function is only available for licenses with the RBAC feature enabled!". If there are more users than the license allows (10 users by default, the @admin user is not counted), it fails with "Your license is currently limited to 10 users. Please consider upgrading the license to more users!" (the number is the limit of the license).

The currently logged in user (see IPS_GetLoggedInUser) must be an administrator, i.e. the @admin user or a user with the @admin role. Otherwise the function fails with "Administrator permissions are required for this action!".

If the user does not exist, the function fails with "User with name '…' does not exist". The @admin user cannot be modified; trying to do so fails with "User @admin cannot be modified!".

Example

IPS_SetUserPassword('anna', 'secret');
Any questions?