Documentation

User and password

User and password functions are used to verify passwords and provide password control.

getfullname

Description

The getfullname() function retrieves the full name of the specified user. This information is taken from the gecos field of /etc/passwd on the policy server host or the password map in NIS.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = getfullname([user]);

Arguments

userOptional. The name of the user ID for which a full name is retrieved. The value of the runuser variable is used when this argument is not specified.

Return values

The full name of the user as specified in the gecos field of /etc/passwd or the NIS password map. An error is returned if the user is null or invalid.

Example

In the example, result is assigned the full name of the runuser.

result = getfullname();

Example

In this example, result is assigned the full name of user1.

result = getfullname("user1");

getgroup

Description

The getgroup() function retrieves the first occurrence of the group name that is associated with the GID to which the specified user belongs. This information is taken from the gecos field of /etc/passwd on the policy server host or the password map in NIS.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = getgroup([user]);

Arguments

userOptional. The name of the user for which the group should be retrieved. If this argument is not
specified, the value of the runuser variable is used.

Return values

If the user is found, result contains the first occurrence of the group name that is associated with the GID to which the specified user belongs as found in /etc/passwd or the NIS password map. An error is returned if the user is null or invalid.

Example

In this example, if SysAdm001 is found, result contains the first occurrence of the group name that is associated with the GID to which the specified user belongs.

result = getgroup("SysAdm001");

getgrouppasswd

Description

The getgrouppasswd() function prompts first for a user (member of the specified group) then for the password of that user.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = getgrouppasswd(group[, prompt[, attempts]]);

Arguments

groupRequired. The name of the group for which a username and password must be entered.
promptOptional. The password prompt that is displayed to the user. If a prompt is not provided, then the following default prompt is displayed: Enter the username and group of someone in the group.
attemptsOptional. Number of attempts that the user gets to enter the correct password. If the user does not enter the correct password in the specified number of attempts, then the task request is rejected. If the number of attempts is not specified, then the default value of 3 is used.

Return values

truePassword matched the user password.
falsePassword did not match the user password.

Example

In this example, a user has one attempt to enter a correct username and password for a member of the HelpDeskUsers group. If the correct password in not entered in one attempt, then result contains 0. If the correct password is entered in one attempt, then result contains 1.

result = getgrouppasswd("HelpDeskUsers", "Please enter HelpDesk Password:", 1);

getgroups

Description

The getgroups() function retrieves a list of all groups to which the specified user belongs. This information is taken from the /etc/groups file on the policy server host or the group map in NIS.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = getgroups([user]);

Arguments

userOptional. The name of the user for which the secondary group names should be retrieved. If this argument is not specified, then the value of the runuser variable is used.

Return values

A list of character strings that contains all of the groups that the user belongs to. An error is returned if the user is invalid or null.

Example

result = getgroups(runuser);

gethome

Description

The gethome() function retrieves the home directory for the specified user. This information is obtained from the home directory field of /etc/passwd or the NIS password map.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = gethome([user]);

Arguments

userOptional. The name of the user for which home directory information should be retrieved. If this argument is not specified, then the value of the runuser variable is used.

Return values

A string that contains the specified user’s home directory from the home directory field of /etc/password or the NIS map. If the user is not found, then result contains a blank string.

Example

result = gethome("JSmith");

In this example, the home directory for the user JSmith is returned in result. For example, /home/JSmith.

getshell

Description

The getshell() function retrieves the default login shell of the specified user. This information is obtained from the shell field of /etc/passwd or the NIS password map.

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = getshell([user]);

Arguments

userOptional. The name of the user for which shell information should be retrieved. If the user is not specified, then the value of the runuser variable is used.

Return values
A string that contains the default login shell for the specified user from the shell field of /etc/password or the password NIS map. If the username is not found or is invalid, then the policy is rejected with an error code.

Example

In this example, the default shell information for the account JSmith is returned in result. For example, /bin/sh.

result = getshell("JSmith");

getstringpasswd

Description

The getstringpasswd() function prompts the user for a password and compares the answer against the previously encrypted password.

The user’s failure to provide the correct password does not automatically result in a rejection of the secured task request. The policy should examine the result of the getstringpasswd() function and respond accordingly.

Syntax

result = getstringpasswd(encryptedpassword\[, prompt [, attempts]]);

Arguments

encryptedpasswordRequired. An encrypted password, which can be generated by pbpasswd. The clear text form of this password is the password that the user is expected to enter.
promptOptional. A user prompt that describes the desired password. If none is specified, then the default prompt Password: is used.
attemptsOptional. Number of attempts the user gets to specify the correct password. The default value for attempts is 3.

Return values

trueThe answer matched the password.
falseThe answer did not match the password.

Example

In this example, result contains true if the user enters the correct Backup Task Password. If the correct password is not entered in two attempts, the function sets result to false.

result = getstringpasswd(<encrypted string>, "Please enter the Backup Task Password: ", 2);

result = submitconfirmuser(user, "Please enter the user's password:", 3);  
if (result != 1) {  
reject;  
}

getuid

Description

The getuid() function returns the user ID number for the specified user. This information is taken from the gecos field of /etc/passwd on the policy server host or the password map in NIS.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

Syntax

result = getuid([user]);

Arguments

userOptional. The name of the user for which a user ID number should be returned. If this argument is not specified, then the value of the runuser variable is used.

Return values

result contains the uid of the specified user of /etc/passwd or the NIS password map. An error is returned if the user is null or invalid.

Example

result = getuid("root");

getuserpasswd

Description

The getuserpasswd() function prompts the user for the password that belongs to the specified user on the policy server. The password is not echoed to the screen as it is typed.

ℹ️

Note

Not supported in Endpoint Privilege Management for Linux (EPM-L).

ℹ️

Note

The user’s failure to provide the correct password does not automatically result in a rejection of the secured task request. The policy should examine the result of the getuserpasswd() function and respond accordingly.

Syntax

result = getuserpasswd(user[, prompt[, attempts[, name, time]]]);

Arguments

userRequired. The user whose password must be entered.
promptOptional. The prompt to display to the user.
attemptsOptional. The number of attempts that the user has to enter the correct password. The default value for attempts is 3.
nameOptional. The name of a file or persistent variable whose age/expiration determines the re-authentication grace period.
If the value starts with a dollar sign ($), it is treated as a persistent variable, otherwise it is treated as a filename.
If name is specified, the time parameter (below) is required.
timeRequired if name argument (above) is specified). The time/expiry date (number of seconds) after which a prompt is forced. getuserpasswd() returns true without prompting the user for a password if one of the following is true:

- The file defined by the name argument exists, and has not been modified in the last time seconds.
- The persistent variable defined by the name argument exists and its expiry date, defined by time, has not been exceeded.

Return values

truePassword matched.
falsePassword did not match.

Example

In this example, result contains true if the user enters the password for the runuser. If the correct password is not entered in three attempts, then the function sets result to false.

result = getuserpasswd(runuser, "Please enter " + runuser _ "'s Password:");

Example

In this example, the file /opt/pbul/gp001 is created at initial successful user authentication and for 5 minutes (300 seconds) thereafter, the user is not prompted for a password as long as the file is not modified.

getuserpasswd(user, "Passwd for "+user+": ", 3, "/opt/pbul/gp001", 300);

📘

For more information, see submitconfirmuser, runconfirmuser, getstringpasswd, and Persistent variables.

ingroup

Description

The ingroup() function determines whether the specified user is a member of the specified group.

Syntax

result = ingroup(user, group);

Arguments

usersRequired. A username.
groupRequired. A group name.

Return values

trueUser is a member of group.
falseUser is not a member of group or the user or group is null or invalid.

Example

In this example, result contains an integer value 1 if user1 belongs to the group admgroup.

result contains an integer value 0 if user1 does not belong to group admgroup.

result = ingroup("user1", "admgroup");

submitconfirmuser

Description

The submitconfirmuser() function controls whether or not a user must enter a password before the current task request is accepted. When this function is set, the user submitting the request is prompted for the password that is associated with the submit host username set in this function.

The user’s failure to provide the correct password does not automatically result in a rejection of the secured task request. The policy should examine the result of the submitconfirmuser() function and respond accordingly.

Syntax

result = submitconfirmuser(user\[, prompt\[, attempts[, name, time]]]);

Arguments

userRequired. A string that contains a username that exists on the submit host.
promptOptional. The prompt text for the password. The default is Enter password for .
attemptsOptional. The number of attempts that the user has to enter the correct password. The default value for attempts is 3.
nameOptional. The name of a persistent variable whose expiration determines the reauthenticate grace period. The value must start with a dollar sign ($), otherwise no grace period is set and submitconfirmuser()automatically prompts for a password.

If name is specified, the time parameter (below) is required.
timeRequired if name argument (above) is specified). The expiry date (number of seconds) after which a prompt is forced. submitconfirmuser() returns true without prompting the user for a password if the persistent variable, defined by the name argument, exists and its expiry date, defined by time, has not been exceeded.

Return values

truePassword matched.
falsePassword did not match.

Example

In this example, the prompt "Please enter the user’s password:" is displayed and the user is allowed three login attempts.

result = submitconfirmuser(user, "Please enter the user's password:", 3);  
if (result != 1) {  
reject;  
}

©2003-2025 BeyondTrust Corporation. All Rights Reserved. Other trademarks identified on this page are owned by their respective owners. BeyondTrust is not a chartered bank or trust company, or depository institution. It is not authorized to accept deposits or trust accounts and is not licensed or regulated by any state or federal banking authority.