Share this page

# web_set_user

Specifies a login string for a web server.

## C Language

    int web_set_user( const char *username, const char *password, const char *[realm\\]host:port );

Authentication Functions

## Java Language

    int object.set_user( String username, String password, String host:port );

Authentication Functions | Java Syntax

Argument | Description
--- | ---
object | An expression evaluating to an object of type WebApi. Usually web for Java. See also Function and Constant Prefixes.
username | The name of the user making the connection. The username argument is limited to 127 characters.
password | The password of the user making the connection. The password argument is limited to 127 characters.
[realm\\]host:port | The URL of the server to log on to, and the port to use. (Format: "host:port"). For example: www.merc–int.com:8080 If no port is specified, the default port for the protocol is used (HTTP – 80, HTTPS – 443, FTP – 21). Specifying a port overrides the default for that protocol. If an empty string ("") is passed, the username and password are applied to all domains unless a different user and password has been set for the domain with another web_set_user call. To specify a realm, add it before the server name: `web_set_user("<user name>", "<password>", "<realm name>\\<server name>:<port>");`

## Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

## Parameterization

The following argument(s) can be parameterized using standard parameterization: username, password, host:port

## General Information

The web_set_user function specifies a login string and password for a web server or proxy server. It can be called more than once if several proxy servers require authentication. web_set_user overrides the run–time proxy authentication settings for user name and password.

When you log onto a server that requires user and password validation, VuGen records a web_set_user statement containing the login details. However, there are some more stringent, authentication methods for which VuGen is unable to insert web_set_user statements. For details, see User Authentication. In such cases, you can add web_set_user into your script manually.

If there is a specific authentication realm required, and VuGen either does not record it or records it together with other realms that are not required, you can use web_set_user to specify the realm. For example:

        web_set_user("my_user", "my_password", "T1Realm\\myserver:29918");

When you run the script, the user authorization is automatically submitted along with every subsequent request to that server. At the end of the script, the authorization is reset.

Limitation: web_set_user has no effect if a proxy autoconfiguration file is specified in Runtime Settings.

This function is supported for all web scripts.

## C Example

### Example 1

The following function was recorded by VuGen when a user logged on to the server called mansfield, using the standard HTTP port:

    web_set_user("abc", "abc", "mansfield:80");

### Example 2

In the following example, the web_set_user function specifies a login string for user "Private1" using the password "secret":

    web_set_user("Private1", "secret", "www.myhost.com:8080");

### Example 3

The following example was inserted manually by the user into the script as the web server "mansfield" uses NTLM authentication. VuGen cannot record NTLM or Digest authentication. Note that for NTLM authentication the domain name "mansfield" followed by a double backslash must be prepended to the user name:

    web_set_user("mansfield\\freddy", "XYZ", "mansfield:80");

### Example 4

In this example, web_set_user is used twice for proxy authentication.

    vuser_init()
    {
        web_set_proxy("sussex:8080");
        web_set_user("dashwood",
            lr_unmask("4042e3e7c8bbbcfde0f737f91f"),
            "sussex:8080");
        web_url("web_url",
            "URL=http://barton/",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            LAST );
        web_set_proxy("norland:8080");
        web_set_user("delaford\pxy1",
            lr_unmask("4042e3f98b5a77"),
            "norland:8080");
        return 0;
    }

## Java Example

### Example 1

The following function was recorded by VuGen when a user logged on to the server called mansfield, using the standard HTTP port:

    web.set_user("abc", "abc", "mansfield:80");

### Example 2

In the following example, the set_user function specifies a login string for user "Private1" using the password "secret":

    web.set_user("Private1", "secret", "www.myhost.com:8080");

### Example 3

The following example was inserted manually by the user into the script as the web server "mansfield" uses NTLM authentication. VuGen cannot record NTLM or Digest authentication. Note that for NTLM authentication the domain name "mansfield" followed by a double backslash must be prepended to the user name:

    web.set_user("mansfield\\freddy", "XYZ", "mansfield:80");

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: