November 30, 2009

Integrating SoloSubmit with Active Directory

Helix ALM
This is an example of how you can integrate SoloSubmit with Active Directory. There are two pieces to make this work. First, you must have a login page to authenticate the user against Active Directory. There are several examples out there, and I have chosen to use ASP.NET with C#. Second, upon successfull authentication, route the user to the SoloSubmit page. In this example, we also query the Active Directory Server for details on the user, like the first and last name, company, e-mail address ,etc...and then passed to solosubmit. Out of the box, the solosubmit form will not know what to do with this information. Javascript provides a method that allows you to parse the URL and get each parameter. Once you have the parameters, setting the fields is easy. Instead of reading the values from the cookie, you can read them from the parameters.

Tech Details

The login/authentication process is being handled by an ASP.NET project written in C#. Once the user is authenticated, it queries the user to grab the following information:
  • First Name
  • Last Name
  • Company
  • Email Address
  • Phone Number
This information is used to build a URL that includes this. The following fields are used in the URL:
  • fname
  • lname
  • company
  • mail
  • phone
In order for the URL to work properly, the base URL should include the database id of the project. Please review this KB article on how to configure this. A JavaScript Function is added to the SoloSubmit code to parse the URL and parse out each of the fields and their values. The code provided out of the box to set the fields from the cookie is modified to use the values passed in the URL.

ASP.NET project

As mentioned above, there are several examples/samples out there on how to integrate a web portal/app with Active Directory. I downloaded a sample Visual Studio project from here. I simply added code to query the rest of the information needed to populate the SoloSubmit form, and build the URL that is used to redirect to SoloSubmit and populate the fields. In the web.config file, the address of the Active Directory is specified. By default is set to 'localhost':
<add key="DefaultActiveDirectoryServer" value="localhost"/>

SoloSubmit.htm changes

The sample download provides a copy of the modified SoloSubmit.htm file. Here are snippets of the modifications made.

JavaScript function to parse out parameters

function getParams()
	var indx = document.URL.indexOf('?');
	if (indx != -1)
		var tempParams = new Object();
		var pairs = document.URL.substring(indx+1,document.URL.length).split('&');
		for (var i=0; i<pairs.length; i++)
			nameVal = pairs[i].split('=');
			tempParams[nameVal[0]] = nameVal[1];
		return tempParams;
var params = getParams();

Populating the fields based on parameters passed

if (fnam.value.length == 0)
   fnam.value = unescape(params["fname"]);
if (lnam.value.length == 0)
   lnam.value = unescape(params["lname"]);
if (cmpy.value.length == 0)
   cmpy.value = unescape(params["company"]);
if (emal.value.length == 0)
   emal.value = unescape(params["mail"]);
if (phon.value.length == 0)
   phon.value = unescape(params["phone"]);


You can download the Visual Studio 2008 project and modified SoloSubmit page from here.