In this article I will explain how to do a .NET class to get config properties from an SSO Affiliate Application.
First of all, we have to add a reference in our project to this DLL:
Common Files\Enterprise Single Sign-On\SDK\Bin\Microsoft.BizTalk.Interop.SSOClient.dll
Then we have to implement a class that implements IPropertyBag, something like this:
using Microsoft.BizTalk.SSOClient.Interop;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace SSOConfig{
public class PropertyBag : IPropertyBag
{
private Hashtable _hashTable;
public PropertyBag()
{
_hashTable= new Hashtable();
}
public void Read(string propName, out object ptrVar, int errorLog)
{
ptrVar = _hashTable[propName];
}
public void Write(string propName, ref object ptrVar)
{
if (_hashTable.ContainsKey(propName))
_hashTable[propName] = ptrVar;
else
_hashTable.Add(propName, ptrVar);
}
}
}
Now, we can implement our class that gets properties from our affiliate application:
using Microsoft.BizTalk.SSOClient.Interop;
using System;
using System.Collections.Generic;
using System.Text;
namespace SSOConfig{
public class SSOSettingsGetter {
private const string SSO_APPLICATION_NAME = "My Application";
private const string SSO_IDENTIFIER_NAME = "ConfigProperties";
public object GetProperty(string propertyName)
{
ISSOConfigStore appStore = new ISSOConfigStore();
PropertyBag pb = new PropertyBag ();
appStore.GetConfigInfo(SSO_APPLICATION_NAME, SSO_IDENTIFIER_NAME, SSOFlag.SSO_FLAG_RUNTIME, pb);
object propertyValue = null;
pb.Read(propertyName, out propertyValue, 0);
return propertyValue;
}
}
}
No comments:
Post a Comment