„LnxUser::modifyUser” változatai közötti eltérés

Innen: IT documentation
Nincs szerkesztési összefoglaló
9. sor: 9. sor:
== Parameters ==
== Parameters ==


; <code>user</code>
; user
: Associative array what contains the user's parameters what needs to be modified.  The structure of the array: [
: Associative array what contains the user's parameters what needs to be modified.  The structure of the array: [
:; <code>'name'</code> => string
:; 'name' => string
:: Mantandory! Name of linux user.
:: Mantandory! Name of linux user.
:; <code>'rename'</code> => string
:; 'rename' => string
:: Optional. Change of the linux user name.
:: Optional. Change of the linux user name.
:; <code>'password'</code> => string
:; 'password' => string
:: Optional. Change of the linux user password.
:: Optional. Change of the linux user password.
:; <code>'uid'</code> => int
:; '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!
:; <code>'gid'</code> => int | string
:; '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!
:; <code>'groups'</code> => array
:; '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.
:; <code>'append'</code> => bool
:; 'append' => 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
:: 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
:; <code>'comment'</code> => string
:; 'comment' => string
:: Optional. Change of comment (display name) of linux user.
:: Optional. Change of comment (display name) of linux user.
:; <code>'home'</code> => string
:; 'home' => string
:: Optional. Change of absolute path of Home directory of linux user.
:: Optional. Change of absolute path of Home directory of linux user.
:; <code>'movehome'</code> => bool
:; 'movehome' => 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
:: Optional. If '''true''', move contents of the Home directory to the new location. If 'home' is not present this parameter will be ineffective
:; <code>'shell'</code> => string
:; 'shell' => string
:: Optional. Change of absolute path of shell for linux user.
:: Optional. Change of absolute path of shell for linux user.
:; <code>'inactive'</code> => int
:; '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.
:; <code>'expire'</code> => int
:; 'expire' => int
:: Optional. Change of date when account will be disabled. Format: <code>timestamp</code>.
:: Optional. Change of date when account will be disabled. Format: timestamp.
:; <code>'nonunique'</code> => bool
:; 'nonunique' => bool
:: Optional. If '''<code>true</code>''', allow to create users with duplicate (non-unique) User ID.
:: Optional. If '''true''', allow to create users with duplicate (non-unique) User ID.
:; <code>'lock'</code> => bool
:; 'lock' => bool
:: Optional. If '''<code>true</code>''' lock, if '''<code>false</code>''' unlock the user account. ]
:: Optional. If '''true''' lock, if '''false''' unlock the user account. ]


== Return Values ==
== Return Values ==

A lap 2021. szeptember 19., 16:00-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 true lock, if false unlock 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 );