# Scripting

This topic describes the different user configuration-related scripts.

## AddUser

public void AddUser(string Username, string Password, int CurrentAccessLevel);

- Adds record to the User table
  - independent of the authentication mode selected
- Input: a comma-separated list, one item for each field in the User table, in the same order as in the table
  - Names in the parameter list of the function are the names of the three default fields, to which you can add any number of custom fields as well.
- Returns: no indication of success. One may use UserExists or Login to verify if adding a user worked.

## ChangePassword

public void ChangePassword(string username, string newPassword);

- Changes the password of the user name submitted
  - can not be used for resetting AD passwords
  - independent of the authentication mode selected
- Inputs:
  - user name as can be found in the User table
  - new password (Designer has no rule checks for passwords)
- Returns: no indication of success. One may use Login to verify if changing the password worked.

## DeleteUser

public void DeleteUser(string username);

- removes users record from the SQLite database
  - independent of authentication mode selected.
  - You can delete the current logged in user!
- Inputs:
  - user name as can be found in the User table
- Returns: no indication of success. One may use UserExists to verify if adding a user worked.

## Login

public bool Login(string username, string password);

- Login to the application with AD or Standard credentials
  - dependent of authentication mode selected
  - $System.Users.CurrentUsername is set to the username of the user who successfully logs in
  - The application's security behavior is based on the level the user provides for the user name and its access level.
- Inputs:
  - user name as can be found in the User table
  - password as found in the database or Active Directory
- Returns: true/false

## Logout

public void Logout();

- logs out of application
  - $System.Users.CurrentUsername becomes blank
  - The application's behavior is based on the user logged in, changes can be implemented by the user through scripting.
- Inputs: none
- Returns: no indication of success. One could check if $System.Users.CurrentUsername is empty.

## UserExists

public bool UserExists(string username);

- See if the user name is in the SQLite table
  - case sensitive
- Inputs:
  - user name as can be found in the User table
- Returns: true/false

## Reference

$System.Users.CurrentUsername - current user successfully logged in.