Search This Blog

Thursday 8 December 2022

Reading the value from SSO within BizTalk Orchestration & Map

Hi there,

Below is the Helper library project that I have created to access the values from the SSO in BizTalk. 

ConfigurationPropertyBag.cs:- 

using Microsoft.BizTalk.SSOClient.Interop;

namespace SAT.Common.SSOClient

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);
        }
    }

}

SSOClient.cs:-

using System;

using Microsoft.BizTalk.SSOClient.Interop;

namespace SAT.Common.SSOClient

{

    public class SSOClient

    {

        private string idenifierGUID = "ConfigProperties";

        /// <summary>

        /// Read method helps get configuration data

        /// </summary>        

        /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>

        /// <param name="propName">The property name to read</param>

        /// <returns>

        ///  The value of the property stored in the given affiliate application of this component.

        /// </returns>

        public string Read(string appName, string propName)

        {

            try

            {

                SSOConfigStore ssoStore = new SSOConfigStore();

                ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();

                ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);

                object propertyValue = null;

                appMgmtBag.Read(propName, out propertyValue, 0);

                return (string)propertyValue;

            }

            catch (Exception e)

            {

                throw e;

            }

        }

    }

} 

SSOInstanceClient.cs:-

namespace SAT.Common.SSOClient

{

    /// <summary>

    /// This class is created for Map purposes.

    /// </summary>

    public class SSOInstanceClient

    {

        public string Read(string appName, string propName)

        {

            var SSOClientobj = new SSOClient();


            return SSOClientobj.Read(appName, propName);

        }

    }

} 

SSOStaticClient.cs:-

using System;

namespace SAT.Common.SSOClient

{

    /// <summary>

    /// This class is created for Orchestration purposes. The class needs to be Serialized

    /// </summary>

    [Serializable]

    public static class SSOStaticClient

    {

        public static string Read(string appName, string propName)

        {

            var SSOClientobj = new SSOClient();

            return SSOClientobj.Read(appName, propName);

        }

    }

}

Usage in the Map:- 

Usage in the Orchestration:- 

strKeyValue = SAT.Common.SSOClient.SSOStaticClient.Read("YourSSOAppName", "YourKey")

Have a great day.

Newly added Distinguished field is not available after re-deployment in BizTalk

Hi there, 

Recently we have come across an issue after deploying a change to the Production. I have added a distinguished field to the existing schema and deployed it to the Production after it was tested on the QA. Everything was perfectly fine in the QA and but it was giving the below error in the orchestration while trying to access the newly added distinguished field in the orchestration.

When we checked the schemas and distinguished fields on the schema in the admin console, we could see the schema was correct.

We used the Azure CI/CD pipeline to deploy to production. It deletes the application and re-adds it but still, the dll's were in the memory of the host instance.

Error:-

Microsoft.XLANGs.RuntimeTypes.RuntimeInternalErrorException   at Microsoft.XLANGs.Core.Part.GetDFDef(String dottedPath) at Microsoft.XLANGs.Core.XSDPart.GetDistinguishedField(String dottedPath)

Cause and Resolution:-

The issue was due to the Host instance that was not restarted. We have restarted the host instances which fixed the issue.

Have a great day.

Sending Email to Multiple recipients using PowerShell

Hi All,  Below is the working code to Send emails to Multiple recipients using PowerShell. [STRING]$PSEmailServer = "YourSMTPServerIPOr...