Skip to main content

BizTalk: How To - Retrieve SSO values from a non-BizTalk server

Assume you have a BizTalk server and a Non-BizTalk server. The BizTalk server has an SSO affiliate application where you have stored some configuration values. Now you want to retrieve the SSO values from your non-BizTalk server. Also assuming you will be running the application as a Windows Service.

Note: Perform Step 1, 2, 7 and 8 on non-BizTalk server.
Step 1. Install ‘SSO Client Utility’
The SSO Client Utility is located at the following location on your BizTalk Server. Copy the file to your non-BizTalk server and then run it.
File Location: (BizTalk Server) C:\Program Files\Common Files\Enterprise Single Sign-On\SSOClientInstall.exe
Step 2. Register COM Object (SSOConfigStore.dll)
1. Copy SSOConfigStore.dll from BizTalk Server to non-BizTalk server.

BizTalk Server Location: C:\Program Files\Common Files\Enterprise Single Sign-On\
Non-BizTalk Server Location: C:\Program Files\Common Files\Enterprise Single Sign-On\

2. On non-BizTalk server, open ‘Command Prompt’ window and ‘cd’ to C:\Program Files\Common Files\Enterprise Single Sign-On\
3. Run ‘regsvr32.exe’ SSOConfigStore.dll’
4. Open "Component Services" window and expand Console Root ... Component Services ... Computers ... My computer ... DCOM Config
Note: Make sure you see the SSOConfigStore in the list.
Note: The following error message will occur if you forget to add this reference.
“[2520] Retrieving the COM class factory for component with CLSID {CF3C637A-0D4E-47BD-9210-DB40A33BD488} failed due to the following error: 8007007e.”
Step 3. Grant adequate permission to the service account
Add the service account to the following group.
1. SSO Administrators
Note: I’m not sure if the service account has to be part of the following two groups but I added for my test.
1. SSO Affiliate Administrators
2. BizTalk Application Users

Step 4. Create new class in your project
I’m using the following class; you may use it for your test too.

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using Microsoft.BizTalk.SSOClient.Interop;
namespace TestRemoteSSO
{
[Serializable]
public class ConfigurationPropertyBag : IPropertyBag
{
private HybridDictionary properties;
internal ConfigurationPropertyBag()
{
properties = new HybridDictionary();
}
public void Read(string propName, out object ptrVar, int errLog)
{
ptrVar = properties[propName];
}
public void Write(string propName, ref object ptrVar)
{
properties.Add(propName, ptrVar);
}
public bool Contains(string key)
{
return properties.Contains(key);
}
public void Remove(string key)
{
properties.Remove(key);
}
}
[Serializable]
public class RemoteSSOCall
{
private static string idenifierGUID = "ConfigProperties";
public static string RemoteRead(string ssoServer, string appName, string propName)
{
try
{
ISSOConfigStore ssoStore = (ISSOConfigStore)new SSOConfigStore();
IPropertyBag ssoStoreBag = ssoStore as IPropertyBag;
object remoteSsoServerName = ssoServer;
ssoStoreBag.Write("CurrentSSOServer", ref remoteSsoServerName);
ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
ssoStore.GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_NONE, (IPropertyBag)appMgmtBag);
object propertyValue = null;
appMgmtBag.Read(propName, out propertyValue, 0);
return (string)propertyValue;
}
catch (Exception e)
{

                System.Diagnostics.Trace.WriteLine(e.Message);                 throw;             }         }     }
}




Parameters:


ssoServer: This is your BizTalk Server name


appName: Enterprise SSO affiliate application name


propName: A field name from the affiliate application.




Step 5. Write a caller program


I created a console project to test on my PC. Since I’ve BizTalk installed on my PC therefore I had to write a windows service so I can deploy the application to a non-BizTalk server for test.




using System;

using System.Collections.Generic;


using System.Text;


using System.Diagnostics;



namespace TestRemoteSSO

{


    public class Program


    {


        private const string _ssoServer = "BTAPPDEV";


        private const string _appName = "AffiliateApplication_Config";


        public static void Main()


        {


            try


            {


                Trace.WriteLine("BamConnection: " + RemoteSSOCall.RemoteRead(_ssoServer, _appName, "BAMConnection"));


                Console.WriteLine("BamConnection: " + RemoteSSOCall.RemoteRead(_ssoServer, _appName, "BAMConnection"));


            }


            catch (Exception e)


            {


                Trace.WriteLine("Exception Caught: " + e.Message + "  " + e.StackTrace);


                Console.WriteLine("Exception Caught: " + e.Message + "  " + e.StackTrace);


            }


            Console.Read();


        }


    }   
}




Step 6. Create Windows Service project


You need to create a service installer before you can install the service on non-BizTalk server. I’m assuming you know how to write a service installer. Make sure you add your project reference to Windows Service Project. In the OnStart method, you may write TestRemoteSSO.Program.Main() to invoke the caller.



Step 7. Install the Windows Service


After the service is installed go to the service “Log On” tab and set the account information. This account must be part of certain groups. Make sure you follow the Step 3 above.




Step 8. Start the Windows Service.


You may use DebugView to see the Trace log.


DebugView can be downloaded free from http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx

Comments