DataScript: avi.http.get_userid


Function avi.http.get_userid()
Description Returns the user ID associated with a connection. The userid may be used by the DataScript in a number of ways, such as evaluating a user against a white or blacklist. This field is also used in the client logs to populate the searchable UserID field. This field is populated via the following methods, prioritized in the following order:

  1. Custom: The userid may be explicitly set by a DataScript via the avi.http.set_userid() command. For instance, DataScript may parse through a cookie to grab a user name or session ID, then insert that value into the user ID field.
  2. Basic Auth: If HTTP Basic Auth is enabled on the Virtual Service and a client authenticates, the username field will be used to populate the userid.
  3. Client Certificate: If client certificate authentication has been enabled, the userid will be populated with the user name field from the client certificate received during the SSL/TLS handshake.
Parameter None
Returns String of the user ID, ‘nil’ if empty.
Example If HTTP header 'username' exists, insert its value into the UserID field, else set the field to none.
if not avi.http.get_userid() then

Note: This API is not supported in the events SSL_PRECONNECT, SSL_CLIENTHELLO, and SSL_HANDSHAKE_DONE.