Sys.Services AuthenticationService login Method

Authenticates the user's credentials.

Sys.Services.AuthenticationService.login(userName, password, isPersistent, customInfo, redirectUrl, loginCompletedCallback, failedCallback, userContext);

Parameters

Parameter

Description

userName

(required) The user name to authenticate.

password

The user's password. The default is null.

isPersistent

true if the issued authentication ticket should be persistent across browser sessions; otherwise, false. The default is false.

redirectUrl

The URL to redirect the browser to on successful authentication. If null, no redirect occurs. The default is null.

customInfo

Reserved for future use. The default is null.

loginCompletedCallback

The function to call when the login has finished successfully. The default is null.

failedCallback

The function to call if the login fails. The default is null.

userContext

User context information that you are passing to the callback functions.

Exceptions

Exception type

Condition

Sys.ArgumentNullException

username is null.

Remarks

If redirectUrl is null or is an empty string, the current page is not refreshed after the call to the authentication Web service finishes. Instead, if the Web service call succeeds, the login-completed function is called.

If redirectUrl is not null or is a non-empty string, the page is redirected to the specified URL after a successful call to the Web service. The redirection URL can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path.

If the call to the Web service fails, the page is not redirected or refreshed. Instead, the failed-callback function is called.

Example

The following example shows how to use the login method to check the user's credentials. This code is part of a complete example found in the Sys.Services.AuthenticationService class overview.

// This function calls the login method of the
// authentication service to verify 
// the credentials entered by the user.
// If the credentials are authenticated, the
// authentication service issues a forms 
// authentication cookie. 
function OnClickLogin() 
{   

    // Set the default callback functions.
    SetDefaultLoginCompletedCallBack();
    SetDefaultLogoutCompletedCallBack();
    SetDefaultFailedCallBack();

    // Call the authetication service to authenticate
    // the credentials entered by the user.
    Sys.Services.AuthenticationService.login(username.value, 
        password.value, false,null,null,null,null,"User Context");
}

See Also

Reference

Sys.Services AuthenticationService logout Method

Concepts

Sys.Services.ProfileService Class

Sys.Net.WebServiceProxy Class