/// <summary>
        /// Gets the list of SSO applications. Only the application metadata information is returned.
        /// </summary>
        /// <returns>List of SSO applications.</returns>
        public static List <SSOAppInfo> GetApplications()
        {
            ISSOMapper2  ssoMapper = new ISSOMapper2();
            IPropertyBag propBag   = ssoMapper as IPropertyBag;

            // prepare filter to only include config store application
            uint   appFilterFlagMask    = SSOFlag.SSO_FLAG_APP_FILTER_BY_TYPE;
            uint   appFilterFlags       = (uint)AffiliateApplicationType.ConfigStore;
            object appFilterFlagsObj    = (object)appFilterFlags;
            object appFilterFlagMaskObj = (object)appFilterFlagMask;

            // set filter in the mapper
            propBag.Write("AppFilterFlags", ref appFilterFlagsObj);
            propBag.Write("AppFilterFlagMask", ref appFilterFlagMaskObj);

            // declare output arrays
            string[] applications  = null;
            string[] descriptions  = null;
            string[] contactInfo   = null;
            string[] userAccounts  = null;
            string[] adminAccounts = null;
            int[]    flags         = null;

            // get applications
            ssoMapper.GetApplications2(out applications, out descriptions, out contactInfo, out userAccounts, out adminAccounts, out flags);

            List <SSOAppInfo> applicationList = new List <SSOAppInfo>();

            for (int index = 0; index < applications.Length; ++index)
            {
                // include only applications created by this tool
                if (SSOManager.DefaultContact.Equals(contactInfo[index], StringComparison.InvariantCultureIgnoreCase) == true)
                {
                    SSOAppInfo appInfo = new SSOAppInfo()
                    {
                        Name          = applications[index],
                        Description   = descriptions[index],
                        AdminAccounts = adminAccounts[index],
                        UserAccounts  = userAccounts[index],
                        Contact       = contactInfo[index],
                        Flags         = flags[index],
                    };
                    applicationList.Add(appInfo);
                }
            }
            return(applicationList);
        }
        /// <summary>
        /// Updates the application metadata information.
        /// </summary>
        /// <remarks>
        /// For internal use only. Assumes a TransactionScope is created before
        /// calling this method.
        /// </remarks>
        /// <param name="ssoAdmin">ISSOAdmin2 instance.</param>
        /// <param name="appInfo">Application metadata information.</param>
        private static void UpdateApplicationInfo(ISSOAdmin2 ssoAdmin, SSOAppInfo appInfo)
        {
            // create a separate instance of the SSOAppInfo object
            // to only copy the information that is updatable
            SSOAppInfo appInfoUpdate = new SSOAppInfo();

            appInfoUpdate.Description  = appInfo.Description;
            appInfoUpdate.Contact      = appInfo.Contact;
            appInfoUpdate.UserAccounts = appInfo.UserAccounts;
            if (appInfo.UseSSOAffiliateAdmins == false)
            {
                appInfoUpdate.AdminAccounts = appInfo.AdminAccounts;
            }

            // update the application
            ssoAdmin.UpdateApplication2(appInfo.Name, appInfoUpdate);
        }
 /// <summary>
 /// Retrieves the specified application metadata information from the SSO store.
 /// </summary>
 /// <param name="appName">The name of the application to retrieve.</param>
 /// <returns>The instance of the SSOAppInfo.</returns>
 public static SSOAppInfo GetApplicationInfo(string appName)
 {
     try
     {
         SSOAppInfo appInfo = new SSOAppInfo()
         {
             Name = appName
         };
         ISSOAdmin2 ssoAdmin = new ISSOAdmin2();
         ssoAdmin.GetApplicationInfo2(appName, appInfo);
         return(appInfo);
     }
     catch
     {
         return(null);
     }
 }
        /// <summary>
        /// Updates the application metadata information.
        /// </summary>
        /// <param name="appInfo">Application metadata information.</param>
        public static void UpdateApplicationInfo(SSOAppInfo appInfo)
        {
            ISSOAdmin2 ssoAdmin = new ISSOAdmin2();

            SSOManager.UpdateApplicationInfo(ssoAdmin, appInfo);
        }
        /// <summary>
        /// Checks whether the specified application exists.
        /// </summary>
        /// <param name="appName">The name of the application.</param>
        /// <returns><b>true</b> if the application exists; otherwise <b>false</b>.</returns>
        public static bool ApplicationExists(string appName)
        {
            SSOAppInfo appInfo = SSOManager.GetApplicationInfo(appName);

            return(appInfo != null);
        }