„LnxUser::addUser” 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)
1. sor: 1. sor:
== Description ==
== Description ==
Object-oriented style<syntaxhighlight lang="php">
Object-oriented style<syntaxhighlight lang="php">
 
public lnxUser::addUser ( array $user ): bool
</syntaxhighlight>Procedural style<syntaxhighlight lang="php">
</syntaxhighlight>Procedural style<syntaxhighlight lang="php">
 
lnxAddUser ( array $user ): bool
</syntaxhighlight>
</syntaxhighlight>Create a linux user with '''user''' parameters.


== Parameters ==
== Parameters ==


; user
: Associative array what contains the new user's parameters.
: The structure of the the array:
: [
:; 'name' => string
:: Mantandory! Name of linux user.
:; 'password' => string
:: Mantandory! Password of linux user.
:; '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. User ID of linux user. The ID must not exist!
:; 'gid' => int | string
:: Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID.
:; 'groups' => array
:: Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
:; 'nogroup' => bool
:: Optional. If '''true''' the Primary group will not be created. If 'gid' is present this parameter will be ineffective.
:; 'comment' => string
:: Optional. Comment (display name) of linux user.
:; 'home' => string
:: Optional. Absolute path of Home directory of linux user.
:; 'createhome' => bool
:: Optional. If '''false''' the Home directory will not be created.
:; 'shell' => string
:: Optional. Absolute path of shell for linux user.
:; 'inactive' => int
:: Optional. The number of days after password expires that account is disabled.
:; 'expire' => int
:: Optional. Date when account will be disabled. Format: timestamp.
:; 'system' => bool
:: Optional. If '''true''' create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective.
:; 'nonunique' => bool
:: Optional. If '''true''' allow to create users with duplicate (non-unique) User ID.
: ]


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


 
Returns '''true''' if user is created, '''false''' otherwise.
== Changelog ==
== Changelog ==
{| class="wikitable"
{| class="wikitable"
!Version<br>(lnxUser)
!Version<br>(lnxUser)
!Description
!Description
|-
|1.2
|add: password hash, salt, round
|-
|-
|1.00
|1.00
24. sor: 66. sor:
<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
$user = 'testUser';
$user = 'testUser';
$group = 'testGroup';
 
# Add linux user
 
if ( ! lnxAddUser( [
'name' => $user, // Mantandory! Name of linux user.
'password' => 'HelloNSA', // Mantandory! Password of linux user.
//'uid' => 1100, // Optional. User ID of linux user. The ID must not exist!
//'gid' => 1100, // Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID.
'groups' => [ 'users' ], // Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
//'nogroup' => true, // Optional. If true the Primary group will not be created. If 'gid' is present this parameter will be ineffective.
'comment' => 'test user', // Optional. Comment (display name) of linux user.
//'home' => '/home/test',// Optional. Absolute path of Home directory of linux user.
//'createhome' => true, // Optional. If false the Home directory will not be created.
//'shell' => '/bin/bash', // Optional. Absolute path of shell for linux user.
//'inactive' => 90, // Optional. The number of days after password expires that account is disabled.
//'expire' => 1640995199, // Optional. Date when account will be disabled. Format: timestamp.
//'system' => true, // Optional. If true create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective.
//'nonunique' => true , // Optional. If true allow to create users with duplicate (non-unique) User ID.
] ) )
print( "Something went wrong during Add user!" . PHP_EOL );
 
else
print( "'$user' user is created." . PHP_EOL );
 


</syntaxhighlight>
</syntaxhighlight>
[[Kategória:LnxUser]]
[[Kategória:LnxUser]]

A lap jelenlegi, 2021. szeptember 23., 20:13-kori változata

Description

Object-oriented style

public lnxUser::addUser ( array $user ): bool

Procedural style

lnxAddUser ( array $user ): bool

Create a linux user with user parameters.

Parameters

user
Associative array what contains the new user's parameters.
The structure of the the array:
[
'name' => string
Mantandory! Name of linux user.
'password' => string
Mantandory! Password of linux user.
'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. User ID of linux user. The ID must not exist!
'gid' => int | string
Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID.
'groups' => array
Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
'nogroup' => bool
Optional. If true the Primary group will not be created. If 'gid' is present this parameter will be ineffective.
'comment' => string
Optional. Comment (display name) of linux user.
'home' => string
Optional. Absolute path of Home directory of linux user.
'createhome' => bool
Optional. If false the Home directory will not be created.
'shell' => string
Optional. Absolute path of shell for linux user.
'inactive' => int
Optional. The number of days after password expires that account is disabled.
'expire' => int
Optional. Date when account will be disabled. Format: timestamp.
'system' => bool
Optional. If true create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective.
'nonunique' => bool
Optional. If true allow to create users with duplicate (non-unique) User ID.
]

Return Values

Returns true if user is created, false otherwise.

Changelog

Version
(lnxUser)
Description
1.2 add: password hash, salt, round
1.00 available

Examples

$user	= 'testUser';

# Add linux user

if ( ! lnxAddUser( [
	
	'name'			=> $user,		// Mantandory! Name of linux user.
	'password'		=> 'HelloNSA',	// Mantandory! Password of linux user.
	//'uid'			=> 1100,		// Optional. User ID of linux user. The ID must not exist!
	//'gid'			=> 1100,		// Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID.
	'groups'		=> [ 'users' ],	// Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
	//'nogroup'		=> true,		// Optional. If true the Primary group will not be created. If 'gid' is present this parameter will be ineffective.
	'comment'		=> 'test user',	// Optional. Comment (display name) of linux user.
	//'home'		=> '/home/test',// Optional. Absolute path of Home directory of linux user.
	//'createhome'	=> true,		// Optional. If false the Home directory will not be created.
	//'shell'		=> '/bin/bash',	// Optional. Absolute path of shell for linux user.
	//'inactive'	=> 90,			// Optional. The number of days after password expires that account is disabled.
	//'expire'		=> 1640995199,	// Optional. Date when account will be disabled. Format: timestamp.
	//'system'		=> true,		// Optional. If true create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective.
	//'nonunique'	=> true	,		// Optional. If true allow to create users with duplicate (non-unique) User ID.
	
	] ) )
	
	print( "Something went wrong during Add user!" . PHP_EOL );

else
	
	print( "'$user' user is created." . PHP_EOL );