Login Method
Description

Authorizes the user. On success, the user is logged in and can connect to projects.

Syntax
Visual Basic
Public Sub Login( _
   ByVal UserName As String, _
   ByVal Password As String _
) 
Parameters

See the following table for the username and password parameters.

ALM version SSO mode Non-SSO mode
14.x

Supports login with the one of the following pairs of username and password:

  • IdP name and IdP password
  • API key and API key secret
NA
12.5x, 12.60 NA

Supports login with the one of the following pairs of username and password:

  • ALM username and password
  • If an LWSSO token is passed as the username, pass an empty string as the password.
15.00

Supports login with the one of the following pairs of username and password:

  • If an LWSSO token is passed as the username, pass an empty string as the password.
  • If an empty string is passes as the username, pass an LWSSO token as the password.

Note: If you want to login with API key and API key secret, you can use the InitConnectionWithApiKey Method API .

Supports login with the one of the following pairs of username and password:

  • ALM username and password
  • If an LWSSO token is passed as the username, pass an empty string as the password.
  • If an empty string is passes as the username, pass an LWSSO token as the password.
15.0.1

Supports login with the one of the following pairs of username and password:

  • If an LWSSO token is passed as the username, pass an empty string as the password.
  • If an empty string is passes as the username, pass an LWSSO token as the password.
  • API key and API key secret

Supports login with the one of the following pairs of username and password:

  • ALM username and password
  • If an LWSSO token is passed as the username, pass an empty string as the password.
  • If an empty string is passes as the username, pass an LWSSO token as the password.
  • API key and API key secret
Remarks

Before authenticating a user with Login, connect to the server with InitConnectionEx.

After a successful call to Login, the user is authenticated on the server, but not connected to any project. Therefore, the LoggedIn Property and the Connected Property are True and the ProjectConnected Property is False.

For a table of properties affected by the state of the connection, see the Remarks for the TDConnection object.

Note that there are other ways to authenticate:

  • Authentication by external Identity Manager (IdM) and Identity Provider (IdP)

    Available in versions: 14.x

    In this case, the Login method is supported for backward compatibility and requires referencing IdmClientSdk.dll and IdmSdkWrapper.dll.

    To use the IdP authentication mechanism, develop your own authentication flow to acquire a LWSSO token from the IdP and IdM that manage authentication (see Acquire an authentication token to use for ALM APIs). Use the token you acquire to call InitConnectionWithCookiesEx Method instead of using this Login method.

  • API keys

    Available in versions: ALM 14.00 Patch 2 and later; ALM 12.60 and later; ALM 15 and later

    In SSO mode, only login with API keys is supported.

    Call the InitConnectionWithApiKey Method or InitConnectionWithApiKeyEx Method to initiate the connection and authenticate with an API key that you obtain from ALM administration. For details, see How to Manage API Keys.

Restricting API access (technical preview)

Available in versions: ALM 12.60 and later

You can restrict API access to a white-list of client types, using the OTA_ACCESS_APIKEY_ONLY site parameter. By default this site parameter is set to N, meaning there is no restriction.

To enable restriction:

  1. Set the OTA_ACCESS_APIKEY_ONLY site parameter to Y.

  2. Add a list of approved client types to the RESTAPI_WHITELIST_APIKEY site parameter, separated by commas.

  3. Add ClientType to your code.

Note: If you use API key and API key secret to login in ALM 15.0.1 or later versions, the API access restriction is not applicable.

Limitation: Under certain circumstances, after enabling API access restriction you may find that you cannot access the ALM server. If this happens, please contact Support for a workaround.

 

For example:

 

C#
	TDConnection tdConn = new TDConnection();
	tdConn.ClientType[ClientType] = ""
	tdConn.InitConnection(serverUrl)
       tdConn.Login("sa", "");

 

VBA / VBScript
Sub initConn()
	Set tdCnn = New TDConnection
	tdCnn.ClientType("hehe") = ""
	tdCnn.InitConnection ("http://localhost:1260/qcbin")
	tdCnn.Login "sa", ""
End Sub
See Also