„LnxUser::modifyUser” változatai közötti eltérés
Innen: IT documentation
(Új oldal, tartalma: „== Description == Object-oriented style<syntaxhighlight lang="php"> </syntaxhighlight>Procedural style<syntaxhighlight lang="php"> </syntaxhighlight> == Parameters…”) |
Nincs szerkesztési összefoglaló |
||
| 1. sor: | 1. sor: | ||
== Description == | == Description == | ||
Object-oriented style<syntaxhighlight lang="php"> | Object-oriented style<syntaxhighlight lang="php"> | ||
public lnxUser::modifyUser ( array $user ): bool | |||
</syntaxhighlight>Procedural style<syntaxhighlight lang="php"> | </syntaxhighlight>Procedural style<syntaxhighlight lang="php"> | ||
lnxModifyUser ( array $user ): bool | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Modify a linux user with user parameters. | |||
== Parameters == | == Parameters == | ||
; <code>user</code> | |||
: Associative array what contains the user's parameters what needs to be modified. The structure of the array: [ | |||
:; <code>'name'</code> => string | |||
:: Mantandory! Name of linux user. | |||
:; <code>'rename'</code> => string | |||
:: Optional. Change of the linux user name. | |||
:; <code>'password'</code> => string | |||
:: Optional. Change of the linux user password. | |||
:; <code>'uid'</code> => int | |||
:: Optional. Change of User ID of linux user. The ID must not exist! | |||
:; <code>'gid'</code> => int | string | |||
:: Optional. Change of primary group of linux user. The group must exist! | |||
:; <code>'groups'</code> => 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. | |||
:; <code>'append'</code> => bool | |||
:: Optional. If '''<code>true</code>''', append the user to the supplemental groups mentioned by the <code>'groups'</code> option, without removing the user from other groups. If <code>'groups'</code> is not present this parameter will be ineffective | |||
:; <code>'comment'</code> => string | |||
:: Optional. Change of comment (display name) of linux user. | |||
:; <code>'home'</code> => string | |||
:: Optional. Change of absolute path of Home directory of linux user. | |||
:; <code>'movehome'</code> => bool | |||
:: Optional. If '''<code>true</code>''', move contents of the Home directory to the new location. If <code>'home'</code> is not present this parameter will be ineffective | |||
:; <code>'shell'</code> => string | |||
:: Optional. Change of absolute path of shell for linux user. | |||
:; <code>'inactive'</code> => int | |||
:: Optional. Change of the number of days after password expires that account is disabled. | |||
:; <code>'expire'</code> => int | |||
:: Optional. Change of date when account will be disabled. Format: <code>timestamp</code>. | |||
:; <code>'nonunique'</code> => bool | |||
:: Optional. If '''<code>true</code>''', allow to create users with duplicate (non-unique) User ID. | |||
:; <code>'lock'</code> => bool | |||
:: Optional. If '''<code>true</code>''' lock, if '''<code>false</code>''' unlock the user account. ] | |||
== Return Values == | == Return Values == | ||
Returns '''true''' if user is modified, '''false''' otherwise | |||
== Changelog == | == Changelog == | ||
{| class="wikitable" | {| class="wikitable" | ||
| 26. sor: | 58. sor: | ||
$user = 'testUser'; | $user = 'testUser'; | ||
$group = 'testGroup'; | $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 ); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Kategória:LnxUser]] | [[Kategória:LnxUser]] | ||
A lap 2021. szeptember 19., 15:59-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.
'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 );