|
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. Follow the following steps to make your dream come true.
Step1. 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.
C:\Program Files\Common Files\Enterprise Single Sign-On\SSOClientInstall.exe
Step2. Setup project references
Add the following DLL reference to your project. You can copy this file from your BizTalk server.
C:\Program Files\Common Files\Enterprise Single Sign-On\SSOConfigStore.dll
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.”
Step3. 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
Step4. 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: The field name from the affiliate application.
Step5. 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;
using Lighthouse1.DebitCardService.BAM.Utility;
namespace TestRemoteSSO
{
public class Program
{
private const string _ssoServer = "BTAPPDEV";
private const string _appName = "FDR_ODS_Security";
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();
}
}
}
Step6. 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.
Step7. 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.
Step8. Start the Windows Service.
You may use DebugView to see the Trace log.
DebugView can be downloaded from http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
As soon as independence has been reached, the adult who keeps on helping become obstacle ... Montessori
|
|
|
|
|
My first message
As soon as independence has been reached, the adult who keeps on helping become obstacle ... Montessori
|
|
|
|