Documentation
IPS_CreateUser
bool IPS_CreateUser (string $User, int $UserType)
Parameters
| User | Name of the new user (case-sensitive) |
| UserType | Type of the user (0 ( |
Returns
If the function succeeds, it returns TRUE, otherwise FALSE.
Description
The function creates a new user with the name User and the type UserType.
| User type | Constant | Description |
|---|---|---|
| 0 | USER_TYPE_LOCAL |
Local account, login with the password set via IPS_SetUserPassword |
| 1 | USER_TYPE_LDAP |
LDAP, login via the LDAP server with the BindDN set via IPS_SetUserBindDN |
Users are usually managed in the Permission Control.
A new user is inactive and has no password, no first and last name, no roles and no permissions. For the user to be able to log in, the user must be activated with IPS_SetUserActive and, for a local account, get a password with IPS_SetUserPassword or, for an LDAP account, a BindDN with IPS_SetUserBindDN.
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!". The new user counts against the user limit of the license (10 users by default, the @admin user is not counted). If the limit would be exceeded, the function 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!".
Further errors:
- An empty name fails with "User cannot be empty".
- The name "token" is reserved for logging in with temporary tokens and fails with "User 'token' is reserved and cannot be used".
- A name that equals the licensee (e-mail address of the license) fails with "User cannot be equivalent to the licensee".
- A user type other than 0 or 1 fails with "Unsupported User Type!".
- If a user with this name already exists, the function fails with "User with name '…' already exists".
See also: IPS_DeleteUser, IPS_GetUser, IPS_AddRoleToUser
Example
IPS_CreateUser('anna', USER_TYPE_LOCAL);
IPS_SetUserPassword('anna', 'secret');
IPS_SetUserFirstName('anna', 'Anna');
IPS_SetUserLastName('anna', 'Muster');
IPS_SetUserActive('anna', true);