/// <summary>
        /// Updates the specified application including both, metadata information
        /// and fields.
        /// </summary>
        /// <param name="appConfig">Configuration information used to update the application.</param>
        /// <param name="recreate">Value indicating wheter to recreate the application.</param>
        public static void UpdateApplication(SSOAppConfig appConfig, bool recreate)
        {
            using (TransactionScope transactionScope = new TransactionScope())
            {
                // create SSO objects
                ISSOAdmin2      ssoAdmin       = new ISSOAdmin2();
                ISSOConfigStore ssoConfigStore = new ISSOConfigStore();

                // enlist them in the transaction
                SSOManager.Enlist(ssoAdmin as IPropertyBag, Transaction.Current);
                SSOManager.Enlist(ssoConfigStore as IPropertyBag, Transaction.Current);

                // check if the application needs to be recreated or just updated
                if (recreate == true)
                {
                    // delete and recreate
                    SSOManager.DeleteApplication(ssoAdmin, appConfig.AppInfo.Name);
                    SSOManager.CreateApplication(ssoAdmin, appConfig);
                }
                else
                {
                    // just update the application metadata
                    SSOManager.UpdateApplicationInfo(ssoAdmin, appConfig.AppInfo);
                }

                // update the application fields
                ssoConfigStore.SetConfigInfo(appConfig.AppInfo.Name, SSOManager.ConfigIdentifier, appConfig.AppFields);
                // commit the transaction
                transactionScope.Complete();
            }
        }
 /// <summary>
 /// Deletes the specified application.
 /// </summary>
 /// <param name="appName">The name of the application to be deleted.</param>
 public static void DeleteApplication(string appName)
 {
     using (TransactionScope transactionScope = new TransactionScope())
     {
         ISSOAdmin2 ssoAdmin = new ISSOAdmin2();
         SSOManager.Enlist(ssoAdmin as IPropertyBag, Transaction.Current);
         SSOManager.DeleteApplication(ssoAdmin, appName);
         transactionScope.Complete();
     }
 }
        /// <summary>
        /// Creates a new application in the SSO store using specified
        /// the configuration information. Creates both, the application
        /// and fields.
        /// </summary>
        /// <param name="appConfig">Configuration information used to create the application.</param>
        public static void CreateApplication(SSOAppConfig appConfig)
        {
            // create a transaction
            using (TransactionScope transactionScope = new TransactionScope())
            {
                // create SSO objects
                ISSOAdmin2 ssoAdmin = new ISSOAdmin2();

                // enlist them in the transaction
                SSOManager.Enlist(ssoAdmin as IPropertyBag, Transaction.Current);

                // create the sso application
                SSOManager.CreateApplication(ssoAdmin, appConfig);

                // commit the transaction
                transactionScope.Complete();
            }

            // update the application fields
            ISSOConfigStore ssoConfigStore = new ISSOConfigStore();

            //SSO.Enlist(ssoConfigStore as IPropertyBag, Transaction.Current);
            ssoConfigStore.SetConfigInfo(appConfig.AppInfo.Name, SSOManager.ConfigIdentifier, appConfig.AppFields);
        }