Home Page › Forums › BizTalk 2004 – BizTalk 2010 › SSO as a Configuration Store Example › SSO as a Configuration Store Example
Got it to work! There were a few changes:
1) CHANGE: public static class SSOConfigHelper
TO: public class SSOConfigHelper
Apparently \”STATIC\” is a new keyword on classes in VS2005.
2) I learned that you cannot just change the variable names stored in SSO, they are predefined in the XML File
[code:1:05d688a10c]<?xml version=\"1.0\"?>
<sso>
<application name=\"AppMgmtUsingSSOApp\">
<description>AppMgmtUsingSSOApp</description>
<appUserAccount>BizTalk Application Users</appUserAccount>
<appAdminAccount>BizTalk Server Administrators</appAdminAccount>
<field ordinal=\"0\" label=\"reserved\" masked=\"no\" />
<field ordinal=\"1\" label=\"connectionString\" masked=\"yes\" />
<flags configStoreApp=\"yes\" allowLocalAccounts=\"yes\" enableApp=\"yes\" />
</application>
</sso>[/code:1:05d688a10c]
3. Here’s my unit test code – many changes:
[quote:05d688a10c]using System;
using NUnit.Framework;
using System.Text;
//using System.Collections.Generic;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
// This is an attempt to port some 2006 Biztalk Sample Code back to 2004
// Neal Walters – 06/27/2006
namespace ABCompany.SSOConfig.Test.Unit
{
/// <summary>
/// Summary description for UnitTester.
/// </summary>
[TestFixture]
public class Tests
{
string baseConnStr = \”server=(local);uid=sa;pwd=pass@word1\”;
// NOTE: This appName must be configured using SSOMANAGE Utility
string appName = \”AppMgmtUsingSSOApp\”;
[Test]
public void SSOConfigHelperReadTest()
{
string getConnStr = SSOConfigHelper.Read
(appName, \”connectionString\”);
// NOTE: the variable name \”connectionString must be predefined as well
// (it’s in the AppMgmtUsingSSOApp.xml file
Assert.AreEqual(baseConnStr, getConnStr);
Console.WriteLine(\”connectionString value in {0} is {1}\”, appName, getConnStr);
}
/// <summary>
/// SSOConfigHelperWriteTest tests the Write method of the SSOConfigHelper class
/// </summary>
[Test]
public void SSOConfigHelperWriteTest()
{
SSOConfigHelper.Write(appName, \”connectionString\”, baseConnStr);
Console.WriteLine (\”Store completed\”);
string readbackConnStr = SSOConfigHelper.Read
(appName, \”connectionString\”);
// NOTE: the variable name \”connectionString must be predefined as well
// (it’s in the AppMgmtUsingSSOApp.xml file
Console.WriteLine (\”Readback ConnectionString Value=\” + readbackConnStr);
Assert.AreEqual(baseConnStr, readbackConnStr);
}
[Test]
// TODO: put the \”expectsException here
public void SSOConfigHelperReadTestBadAppname()
{
string getConnStr = SSOConfigHelper.Read(\”badAppName\”, \”MySecretConnectionString\”);
Assert.AreEqual(baseConnStr, getConnStr);
Console.WriteLine(\”connectionString value in {0} is {1}\”, appName, getConnStr);
}
[Test]
public void SSOConfigHelperReadTestBadVarname()
{
string getConnStr = SSOConfigHelper.Read(appName, \”MyNonExistingVarName\”);
Assert.AreEqual(null, getConnStr);
Console.WriteLine(\”connectionString value in {0} is {1}\”, appName, getConnStr);
}
} // end class
} // end namespace [/quote:05d688a10c]
4) Also had to make a reference to C:\\Program Files\\Common Files\\Enterprise Single Sign-On\\Microsoft.BizTalk.Interop.SSOClient.dll
(their sample referenced a similar program directly in the GAC).