Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2013-07-12 15:30:21

steve
Third Light Staff
Registered: 2013-06-06
Posts: 105

Automatically log a user into IMS

If you have an existing Intranet portal, you may wish to allow users to access IMS without having to log in separately.
To achieve this, you can use the IMS API from your intranet application to create an authenticated URL that will log the user directly into their account on the IMS system.

This example makes use of the PHP API client

<?php
require_once("imsapiclient.php");
 
// URL of the IMS site
$strIMSSite = "http://yoursite.com";
// API key generated from Configuration -> Site Options -> IMS API
$strAPIKey = "XyKuND7TyhCEXUqB8hxfe4EWwQzFycfo";
 
// The user to log in - this can be a username or e-mail address
// and would correspond to the authenticated user in the
// intranet application
$strUserToLogIn = "joe.bloggs@example.com";
 
try
{
    $objAPI = new IMSApiClient($strIMSSite, $strAPIKey);
    $UserInfo = $objAPI->ImpersonateUser(array("userRef"=>$strUserToLogIn,"lookupType"=>"email"));
    header("Location: $strIMSSite/?formphpsessionid=".$UserInfo["sessionId"]);
}
catch(IMSApiClientException $e)
{
    header("HTTP/1.1 500 Internal Server Error");
    echo "<!DOCTYPE html>\n<html><head><title>Error</title></head><body><h1>Error: ".get_class($e)."</h1><p>".$e->getMessage()."</p></body></html>";
}

In the example code, after the $UserInfo object is retrieved, provided IMS accepts the request for the user impersonation, it returns an array of data about the user. There is a session ID in $UserInfo["sessionid"]. This is the token needed to impersonate the user.

The redirection to $strIMSSite/?formphpsessionid=$UserInfo["sessionId"] is intended to be handled by the client's browser. This URL will cause them to log directly into IMS, bypassing the login screen.

Offline

Board footer