LnxUser::modifyUser
Innen: IT documentation
Description
Object-oriented style
public lnxUser::modifyUser ( array $user ): bool
Procedural style
lnxModifyUser ( array $user ): bool
Modify a linux user with user parameters.
Parameters
user- Associative array what contains the user's parameters what needs to be modified. The structure of the array: [
'name'=> string- Mantandory! Name of linux user.
'rename'=> string- Optional. Change of the linux user name.
'password'=> string- Optional. Change of the linux user password.
'uid'=> int- Optional. Change of User ID of linux user. The ID must not exist!
'gid'=> int | string- Optional. Change of primary group of linux user. The group must exist!
'groups'=> array- Optional. Change of group membership. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
'append'=> bool- Optional. If
true, append the user to the supplemental groups mentioned by the'groups'option, without removing the user from other groups. If'groups'is not present this parameter will be ineffective 'comment'=> string- Optional. Change of comment (display name) of linux user.
'home'=> string- Optional. Change of absolute path of Home directory of linux user.
'movehome'=> bool- Optional. If
true, move contents of the Home directory to the new location. If'home'is not present this parameter will be ineffective 'shell'=> string- Optional. Change of absolute path of shell for linux user.
'inactive'=> int- Optional. Change of the number of days after password expires that account is disabled.
'expire'=> int- Optional. Change of date when account will be disabled. Format:
timestamp. 'nonunique'=> bool- Optional. If
true, allow to create users with duplicate (non-unique) User ID. 'lock'=> bool- Optional. If
truelock, iffalseunlock the user account. ]
Return Values
Returns true if user is modified, false otherwise
Changelog
| Version (lnxUser) |
Description |
|---|---|
| 1.00 | available |
Examples
$user = 'testUser';
$group = 'testGroup';
# Modify linux user
if ( ! lnxModifyUser ( [
'name' => $user, // Mantandory! Name of linux user.
//'rename' => 'renamedTestUser', // Optional. Change of the linux user name.
'password' => 'HelloAgainNSA', // Optional. Change of the linux user password.
//'uid' => 1200, // Optional. Change of User ID of linux user. The ID must not exist!
//'gid' => 1200, // Optional. Change of primary group of linux user. The group must exist!
'groups' => [ $group ], // Optional. Change of group membership. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
'append' => true, // Optional. If true, append the user to the supplemental groups mentioned by the 'groups' option, without removing the user from other groups. If 'groups' is not present this parameter will be ineffective.
'comment' => 'Renamed Test User', // Optional. Change of comment (display name) of linux user.
//'home' => '/home/newtest', // Optional. Change of absolute path of Home directory of linux user.
//'movehome' => true, // Optional. If true, move contents of the Home directory to the new location. If 'home' is not present this parameter will be ineffective.
//'shell' => '/bin/sh', // Optional. Change of absolute path of shell for linux user.
//'inactive' => 90, // Optional. Change of the number of days after password expires that account is disabled.
//'expire' => 1640995199, // Optional. Change of date when account will be disabled. Format: timestamp.
//'nonunique' => true, // Optional. If true, allow to create users with duplicate (non-unique) User ID.
//'lock' => false, // Optional. If true lock, if false unlock the user account.
] ) )
print( "Something went wrong during Modify user!" . PHP_EOL );
else
print( "'$user' user is modified." . PHP_EOL );