Search code examples
single-sign-onbiztalk

How to write to the SSO from BizTalk during run time


I have a requirement where I have to write a value to the SSO store during run time. I found a lot of blogs about reading from the SSO but having no luck in finding a blog that talks about writing to the SSO during run time.


Solution

  • What you need is a method to call ISSOConfigStore.SetConfigInfo(String, String, IPropertyBag) Method added to the helper class for SSO

    The below code as per T Hemani's/theman post on MSDN/Technet

     public static void Write(string appName, string propName, string propValue)
             {
                 try
                 {
                     ISSOConfigStore configStore = (ISSOConfigStore)new SSOConfigStore();
                     ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
                     object tempProp = propValue;
                     try
                     {
                         appMgmtBag.Remove(propName);
                     }
                     catch { }
                     appMgmtBag.Write(propName, ref tempProp);
                     configStore.SetConfigInfo(appName, idenifierGUID, (IPropertyBag)appMgmtBag);
                 }
                 catch (Exception e)
                 {
                     System.Diagnostics.Trace.WriteLine(e.Message);
                     throw;
                 }
             }