1.3 Authenticate API

1.3.1 Connect

Syntax

connect (String username, String password)connect (String sourceId, String username, String password)

Description

This API logs you into the system. You must be logged in before you can call most other functions.

All web services calls, including Connect, observe the session time out constraints defined at the container and application levels. In order to maintain the session flags, the ‘maintainSession’ flag must be set to true on the org.apache.axis.client.Service object using the service. If managing session state manually, the http headers must be preserved for all subsequent interactions. Failure to maintain the headers will result in errors stating that the current session is not logged in.

Parameters

The following are the input parameters for this API:

  1. username: A unique username for this account.

  2. password: A unique password for this account.

  3. sourceId: The sourceId of the LDAP or AD source. Use getLdapSources() to return a list of all known authentication servers. If using PHP or a language that does not use method overloading use “-1″ as the sourceId to simulate null.

Return Value

The following functions should be called to get return values for this API:

  1. To get the value of the ‘success’ field, use get("success"). The value returned in the ‘success’ field will be a string representation of a boolean (‘true or false’) indicating whether or not the login attempt was successful. If the login attempt fails for any reason the ‘success’ field is ‘false’.

  2. To get the value of the ‘message’ field, use get("message"). The value returned in the ‘message’ field will be a text message that explains the response. If the login attempt fails for any reason the ‘message’ field will explain why the failure occurred

Example

$baseService = "http://www.myhost.com/LiveTime/WebObjects/LiveTime.woa/ws/";$objClient = new SoapClient($baseService . "Authenticate?wsdl", array('trace' => true));$results = $objClient->connect($username, $password);//This will return an Associative Array$success = $results['success'];if ($success=="false") { echo $results['message'] . "n"; exit();}echo "Login Successfuln";

1.3.2 Disconnect

Syntax

disconnect()

Description

This API logs you out of the system.

Parameters

None

Return Value

This API returns a HashMap containing two fields: success and message.

The values returned in the two fields of the HashMap are:

  1. The value returned in the success field will be a string representation of a boolean (‘true’ or ‘false’) indicating whether or not the attempt to log out was successful.

  2. The value returned in the message field will be a text message that explains the response. If the request fails for any reason (i.e. the ‘success’ field is ‘false’), the ‘message’ field will explain why the failure occurred. Otherwise, you will see Logged Out displayed.

Example

function logout() { global $objClient; global $baseService; $objClient->SoapClient($baseService . "Authenticate?wsdl", array('trace' => true)); $results = $objClient->disconnect(); //This will return an Associative Array $success = $results['success']; if ($success=="false") { echo $results['message'] . "n"; exit(); } echo "Logout Successfuln"; exit();}

1.3.3 getLdapSources

Syntax

getLdapSources()

Description

This API returns a list of all LDAP sources when using the new multi-source authentication services in Service Desk.

Parameters

None