„LnxUser::modifyUser” változatai közötti eltérés
Innen: IT documentation
Nincs szerkesztési összefoglaló |
|||
| (6 közbenső módosítás ugyanattól a szerkesztőtől nincs mutatva) | |||
| 9. sor: | 9. sor: | ||
== Parameters == | == Parameters == | ||
; | ; user | ||
: Associative array what contains the user's parameters what needs to be modified. | : 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. | :: Mantandory! Name of linux user. | ||
:; | :; 'rename' => string | ||
:: Optional. Change of the linux user name. | :: Optional. Change of the linux user name. | ||
:; | :; 'password' => string | ||
:: Optional. Change of the linux user password. | :: Optional. Change of the linux user password. | ||
:; | :; 'hash' => string | ||
:: Optional. Password hash method. The method must be one of [[LnxUser PHP Class Reference|LNX_PH family of constants]]. If 'password' is not present this parameter will be ineffective. | |||
:; 'salt' => string | |||
:: Optional. Password hash salt. You can read about password hash, salt, round relationships and requirements [https://www.php.net/manual/en/function.crypt here]. If 'password' is not present this parameter will be ineffective. | |||
:; 'round' => string | int | |||
:: Optional. Password hash round. You can read about password hash, salt, round relationships and requirements [https://www.php.net/manual/en/function.crypt here]. If 'password' is not present this parameter will be ineffective. | |||
:; 'uid' => int | |||
:: Optional. Change of User ID of linux user. The ID must not exist! | :: 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! | :: 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. | :: 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 ''' | :: 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. | :: Optional. Change of comment (display name) of linux user. | ||
:; | :; 'home' => string | ||
:: Optional. Change of absolute path of Home directory of linux user. | :: Optional. Change of absolute path of Home directory of linux user. | ||
:; | :; 'movehome' => bool | ||
:: Optional. If ''' | :: 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. | :: 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. | :: 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: | :: Optional. Change of date when account will be disabled. Format: timestamp. | ||
:; | :; 'nonunique' => bool | ||
:: Optional. If ''' | :: Optional. If '''true''', allow to create users with duplicate (non-unique) User ID. | ||
:; | :; 'lock' => bool | ||
:: Optional. If ''' | :: Optional. If '''true''' lock, if '''false''' unlock the user account. | ||
: ] | |||
== Return Values == | == Return Values == | ||
| 49. sor: | 58. sor: | ||
!Version<br>(lnxUser) | !Version<br>(lnxUser) | ||
!Description | !Description | ||
|- | |||
|1.2 | |||
|add: password hash, salt, round | |||
|- | |- | ||
|1.00 | |1.00 | ||
A lap jelenlegi, 2021. szeptember 23., 20:13-kori változata
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.
- 'hash' => string
- Optional. Password hash method. The method must be one of LNX_PH family of constants. If 'password' is not present this parameter will be ineffective.
- 'salt' => string
- Optional. Password hash salt. You can read about password hash, salt, round relationships and requirements here. If 'password' is not present this parameter will be ineffective.
- 'round' => string | int
- Optional. Password hash round. You can read about password hash, salt, round relationships and requirements here. If 'password' is not present this parameter will be ineffective.
- '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 true lock, if false unlock the user account.
- ]
Return Values
Returns true if user is modified, false otherwise
Changelog
| Version (lnxUser) |
Description |
|---|---|
| 1.2 | add: password hash, salt, round |
| 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 );