/// <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> /// Saves the Config Store in the Enterprise Single Sign-On (SSO). /// </summary> internal void Save() { var configStore = new ISSOConfigStore(); var retryCount = 0; while (true) { try { configStore.SetConfigInfo(_affiliateApplicationName, _identifier, this); break; } catch (COMException exception) { // see https://github.com/BTDF/DeploymentFramework/blob/4f047b6ac7067d369365c8776aefe3f4958278a7/src/Tools/SSOSettingsFileImport/SSOSettingsFileImport/SSOHelper.cs#L75 // This error occurs randomly and in virtually all cases, an immediate retry succeeds. // Error Code = 'The external credentials in the SSO database are more recent.' if ((uint)exception.ErrorCode != 0xC0002A40) { throw; } if (++retryCount >= 5) { throw; } } } }
/// <summary> /// Saves the application settings for the informed BizTalk application. /// </summary> /// <param name="applicationName">BizTalk application name.</param> public void Save(string applicationName) { // Creates an settings object from the properties. settings ssoSettings = new settings(); List <settingsProperty> ssoSettingsPropertyList = new List <settingsProperty>(); foreach (var setting in this.Settings) { ssoSettingsPropertyList.Add( new settingsProperty() { name = setting.Key, Value = setting.Value } ); } ssoSettings.property = ssoSettingsPropertyList.ToArray(); object ssoPropertyValue = SerializationHelper.Instance.Serialize <settings>(ssoSettings); this.PropertyBag.Write(SSOSettingsManager.PropName, ref ssoPropertyValue); ISSOConfigStore configStore = (ISSOConfigStore) new SSOConfigStore(); configStore.SetConfigInfo(applicationName, SSOSettingsManager.UID, this.PropertyBag); }
/// <summary> /// Saves the config info. /// </summary> internal static void SaveConfigInfo(string affiliateApplication, string settings) { object settingsObj = (object)settings; SSOPropertyBag bag = new SSOPropertyBag(); bag.Write(PropName, ref settingsObj); int retryCounter = 5; ISSOConfigStore ssoConfigStore = new ISSOConfigStore(); while (retryCounter >= 0) { try { ssoConfigStore.SetConfigInfo(affiliateApplication, InfoIdentifier, bag); break; } catch (System.Runtime.InteropServices.COMException ex) { // Error Code = 'The external credentials in the SSO database are more recent.' // This error occurs randomly and in virtually all cases, an immediate retry succeeds. // Tried just about everything to prevent it with no luck, so retry seems to be the best option. if (ex.ErrorCode != -1073731008) { throw; // All other errors just rethrow } Trace.Write("Caught 'The external credentials in the SSO database are more recent' exception. "); if (retryCounter == 0) { Trace.WriteLine("Exhausted retries."); throw; } else { Trace.WriteLine("Retries remaining: " + retryCounter.ToString()); } } retryCounter--; } }
public void SaveApplicationData(string appName, string[] arrKeys, string[] arrValues) { try { int num = arrKeys.Length; SSOPropertyBag sSOPropertyBag = new SSOPropertyBag(); for (int i = 0; i < num; i++) { sSOPropertyBag.SetValue <string>(arrKeys[i], arrValues[i]); } ISSOConfigStore iSSOConfigStore = (ISSOConfigStore) new SSOConfigStore(); iSSOConfigStore.SetConfigInfo(appName, SSO.CONFIG_NAME, sSOPropertyBag); } catch (Exception ex) { EventLog.WriteEntry("SSOConfigCmdTool - SaveApplicationData", ex.Message); } }
public void SaveApplicationData(string appName, string[] arrKeys, string[] arrValues) { try { int num = arrKeys.Length; SSOPropertyBag sSOPropertyBag = new SSOPropertyBag(); for (int i = 0; i < num; i++) { sSOPropertyBag.SetValue <string>(arrKeys[i], arrValues[i]); DoSsoEvent("SaveApplicationData", string.Format("Key={0}, Value={1}", arrKeys[i], arrValues[i]), false); } ISSOConfigStore iSSOConfigStore = (ISSOConfigStore) new SSOConfigStore(); iSSOConfigStore.SetConfigInfo(appName, SSO.CONFIG_NAME, sSOPropertyBag); } catch (Exception ex) { DoSsoEvent("SSO Helper - SaveApplicationData", ex.Message, true); } }
public static void UpdateApplicationFields(string appName, SSOAppFieldCollection appFields, bool recreate) { if (recreate == true) { SSOAppConfig appConfig = new SSOAppConfig() { // load the current application metadata information AppInfo = SSOManager.GetApplicationInfo(appName), // and use the application fields provided AppFields = appFields }; // update/recreate the application including the fields SSOManager.UpdateApplication(appConfig, true); } else { // just update the application fields ISSOConfigStore ssoConfigStore = new ISSOConfigStore(); ssoConfigStore.SetConfigInfo(appName, SSOManager.ConfigIdentifier, appFields); } }
/// <summary> /// Saves the Config Store in the Enterprise Single Sign-On (SSO). /// </summary> internal void Save() { var configStore = new ISSOConfigStore(); var retryCount = 0; while (true) { try { configStore.SetConfigInfo(_affiliateApplicationName, _identifier, this); break; } // see https://github.com/BTDF/DeploymentFramework/blob/4f047b6ac7067d369365c8776aefe3f4958278a7/src/Tools/SSOSettingsFileImport/SSOSettingsFileImport/SSOHelper.cs#L75 // This error occurs randomly and in virtually all cases, an immediate retry succeeds. catch (COMException exception) when((uint)exception.ErrorCode == (uint)HResult.ErrorSsoDbExternalCredentialsAreMoreRecent) { if (++retryCount >= 5) { throw; } } } }
/// <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); }
/// <summary> /// Set values for application fields /// </summary> /// <param name="appName"></param> /// <param name="propertyBag"></param> public static void SetConfigProperties(string appName, SsoPropBag propertyBag) { ISSOConfigStore configStore = new ISSOConfigStore(); configStore.SetConfigInfo(appName, IdenifierGuid, propertyBag); }
/// <summary> /// Set values for application fields /// </summary> /// <param name="appName"></param> /// <param name="propertyBag"></param> public static void SetConfigProperties(string appName, SSOPropBag propertyBag) { ISSOConfigStore configStore = new ISSOConfigStore(); configStore.SetConfigInfo(appName, idenifierGUID, propertyBag); }