<sso>
<application name="upzoneSSO">
<description>The upzoneSSO application</description>
<contact>upzone@126.com</contact>
<appuserAccount>BTS2006R2\upzone</appuserAccount>
<appAdminAccount>BTS2006R2\administrator</appAdminAccount>
<field ordinal="0" label="Reserved" masked="no"/>
<field ordinal="1" label="User Id" masked="no" />
<field ordinal="2" label="Password" masked="yes" />
<flags groupApp="no" configStoreApp="yes" allowTickets="no" validateTickets="yes" allowLocalAccounts="yes" timeoutTickets="yes" adminAccountSame="no" enableApp="no" />
</application>
</sso>
Notice the 0 ordinal being reserved, this must be set as so, or an exception is thrown. 0号的是sso内部保留的,一定要加上,否则会出错
<field ordinal="0" label="Reserved" masked="no"/>
同时注意,对于此类应用,需要注明configStoreApp="yes".否则无法继续set操作
操作步骤:
1.设置Path变量:
set path=%path%;C:\Program Files\Common Files\Enterprise Single Sign-On
2.create new app.
ssomanage -createapps upzoneSSO\upzoneSSOApp.xml
3.enable app
ssomanage -enableapp upzoneSSO
4.编译BTSScnSSOApplicationConfig.exe工具,位于C:\Program Files\Microsoft BizTalk Server 2006\SDK\Scenarios\Common\SSOApplicationConfig
5.使用以下命令设定值
BTSScnSSOApplicationConfig -set upzoneSSO ConfigProperties "User Id" sa Password upzone
6.测试get value
D:\Dev\SSODemo>BTSScnSSOApplicationConfig -get upzoneSSO ConfigProperties "Password"
Property <Password> = <upzone>
D:\Dev\SSODemo>BTSScnSSOApplicationConfig -get upzoneSSO ConfigProperties "User Id"
Property <User Id> = <sa>
7.C# Coding
public string identifierGUID="ConfigProperties";
public static string Read(string appName, string propName)
{
try
{
SSOConfigStore ssoStore = new SSOConfigStore();
ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
((ISSOConfigStore) ssoStore).GetConfigInfo(appName, identifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag) appMgmtBag);
object propertyValue = null;
appMgmtBag.Read(propName, out propertyValue, 0);
return (string)propertyValue;
}
catch (Exception e)
{
throw;
}
}
public static void Write(string appName, string propName, string propValue)
{
try
{
SSOConfigStore ssoStore = new SSOConfigStore();
ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
object tempProp = propValue;
appMgmtBag.Write(propName, ref tempProp);
((ISSOConfigStore)ssoStore).SetConfigInfo(appName, identifierGUID, appMgmtBag);
}
catch (Exception e)
{
throw;
}
}
Notice the use of the ConfigurationPropertyBag object which is just a class that inherits from IPropertyBag which signature looks like this:
public interface IPropertyBag
{
void Read(string propName, out object ptrVar, int errorLog);
void Write(string propName, ref object ptrVar);
}