Caché ObjectScript Reference
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Class Reference   

Contains the username for the current process.
$USERNAME contains the username for the current process. This can be in one of two forms:
To allow multiple security domains, go to the Management Portal, select [Home] > [Security Management] > [System Security Settings] > [System-wide Security Parameters]. Select the Allow multiple security domains check box. Changes to this setting apply to new invoked processes; changing it does not affect the value returned by the current process.
You cannot use the SET command or the NEW command to modify this value. However, NEW $ROLES also stacks the current $USERNAME value.
Commonly, the $USERNAME value is the username specified at connection time. However, if unauthenticated access is permitted, a user terminal or an ODBC client may connect to Caché without specifying a username. In this case, $USERNAME contains the string “UnknownUser”.
When a process is created using the JOB command, it inherits the same $USERNAME and $ROLES values as its parent process.
A username can be created using the SQL CREATE USER statement and deleted using the SQL DROP USER statement. A user password can be changed using the SQL ALTER USER statement. A user can have roles assigned to it, either by using the SQL GRANT statement, or by using system utilities to add a role to the user. You can access the list of roles assigned to the current process with the $ROLES special variable. A role can be revoked from a user using the SQL REVOKE statement.
$USERNAME is used in Caché SQL as the USER, CURRENT_USER, and SESSION_USER default field values.
You can return the username for the current process, or for a specified process, by invoking the $SYSTEM.Process.UserName() method.
The following example returns the username for the current process.
The following example returns the domain name for the current process.
See Also