/// <summary> /// Creates a new SSO ConfigStore application. /// </summary> /// <param name="appName"></param> /// <param name="description"></param> /// <param name="uAccountName"></param> /// <param name="adminAccountName"></param> /// <param name="propertiesBag"></param> /// <param name="maskArray"></param> public static void CreateConfigStoreApplication(string appName, string description, string uAccountName, string adminAccountName, SsoPropBag propertiesBag, ArrayList maskArray) { int appFlags = 0; //bitwise operation for flags appFlags |= SSOFlag.SSO_FLAG_APP_CONFIG_STORE; appFlags |= SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL; appFlags |= SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL; ISSOAdmin ssoAdmin = new ISSOAdmin(); //create app ssoAdmin.CreateApplication(appName, description, "", uAccountName, adminAccountName, appFlags, propertiesBag.PropertyCount); //create property fields int counter = 0; //create dummy field in first slot ssoAdmin.CreateFieldInfo(appName, "dummy", 0); //create real fields foreach (DictionaryEntry de in propertiesBag.Properties) { string propName = de.Key.ToString(); int fieldFlags = 0; fieldFlags |= Convert.ToInt32(maskArray[counter]); //create property ssoAdmin.CreateFieldInfo(appName, propName, fieldFlags); counter++; } //enable application ssoAdmin.UpdateApplication(appName, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); }
/// <summary> /// Creates a new SSO ConfigStore application. /// </summary> /// <param name="appName"></param> /// <param name="description"></param> /// <param name="uAccountName"></param> /// <param name="adminAccountName"></param> /// <param name="propertiesBag"></param> /// <param name="maskArray"></param> public static void CreateConfigStoreApplication(string appName, string description, string uAccountName, string adminAccountName, SSOPropBag propertiesBag, ArrayList maskArray) { int appFlags = 0; //bitwise operation for flags appFlags |= SSOFlag.SSO_FLAG_APP_CONFIG_STORE; appFlags |= SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL; appFlags |= SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL; ISSOAdmin ssoAdmin = new ISSOAdmin(); //create app ssoAdmin.CreateApplication(appName, description, "ControlCenter", uAccountName, adminAccountName, appFlags, propertiesBag.PropertyCount); //create property fields int counter = 0; //create dummy field in first slot ssoAdmin.CreateFieldInfo(appName, "dummy", 0); //create real fields foreach (DictionaryEntry de in propertiesBag.properties) { string propName = de.Key.ToString(); int fieldFlags = 0; fieldFlags |= Convert.ToInt32(maskArray[counter]); //create property ssoAdmin.CreateFieldInfo(appName, propName, fieldFlags); counter++; } //enable application ssoAdmin.UpdateApplication(appName, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); }
/// <summary> /// Adds SSO application /// </summary> /// <param name="name">Application name</param> /// <param name="admins">Application admin group</param> /// <param name="users">Application users group</param> /// <returns>True if successful, otherwise false</returns> public static bool AddApplication(string name, string admins, string users) { try { ISSOAdmin admin = new ISSOAdmin(); // Create application admin.CreateApplication(name, "SSO Sample Application", "*****@*****.**", users, admins, SSOFlag.SSO_WINDOWS_TO_EXTERNAL | SSOFlag.SSO_FLAG_ALLOW_TICKETS | SSOFlag.SSO_FLAG_VALIDATE_TICKETS, 2); // Add fields admin.CreateFieldInfo(name, "User Id", SSOFlag.SSO_FLAG_NONE); admin.CreateFieldInfo(name, "Password", SSOFlag.SSO_FLAG_FIELD_INFO_MASK); // Enable application admin.UpdateApplication(name, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); } catch { return(false); } return(true); }
private void EnsureSettingsFieldExists() { if (_settingsFieldExists) { return; } var ssoAdmin = new ISSOAdmin(); ssoAdmin.CreateFieldInfo(_affiliateApplicationName, AffiliateApplication.DEFAULT_SETTINGS_KEY, SSOFlag.SSO_FLAG_NONE); ssoAdmin.UpdateApplication(_affiliateApplicationName, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); _settingsFieldExists = true; }
private void EnableApplication(string appName, ISSOAdmin admin) { try { int num = 2; admin.UpdateApplication(appName, null, null, null, null, num, num); } catch (Exception ex) { EventLog.WriteEntry("SSOConfigCmdTool - EnableApplication", ex.Message); } }
private void EnableApplication(string appName, ISSOAdmin admin) { try { int num = 2; admin.UpdateApplication(appName, null, null, null, null, num, num); DoSsoEvent("EnableApplication", string.Format("{0} enabled", appName), false); } catch (Exception ex) { DoSsoEvent("SSO Helper - EnableApplication", ex.Message, true); } }
/// <summary> /// Create an SSO application. /// </summary> /// <param name="application">The name of the affiliate application.</param> /// <param name="type">The type of affiliate application.</param> /// <param name="description">A description for the affiliate application.</param> /// <param name="contact">Contact information for administering the affiliate application.</param> /// <param name="userGroup">The windows group for users that will use the affiliate application.</param> /// <param name="adminGroup">The windows group for administrators of the affiliate application.</param> /// <param name="tickets">A flag indicating if the affiliate application can be used to create SSO tickets.</param> /// <param name="local">A flag indicating whether or not local user accounts can use the affiliate application.</param> public void Create(string application, AffiliateApplicationType type, string description, string contact, string userGroup, string adminGroup, bool tickets, bool local) { try { int flags = 0; int fields = 2; // Set flags. if (type == AffiliateApplicationType.Individual) { flags = SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL; } else if (type == AffiliateApplicationType.Group) { flags = SSOFlag.SSO_WINDOWS_TO_EXTERNAL; flags = flags | SSOFlag.SSO_FLAG_APP_GROUP; flags = flags | SSOFlag.SSO_FLAG_APP_USES_GROUP_MAPPING; } else if (type == AffiliateApplicationType.HostGroup) { flags = SSOFlag.SSO_EXTERNAL_TO_WINDOWS; flags = flags | SSOFlag.SSO_FLAG_APP_GROUP; flags = flags | SSOFlag.SSO_FLAG_APP_USES_GROUP_MAPPING; } else { throw new Exception("Unsupported affiliate application type: " + type.ToString() + "."); } if (tickets) { flags = flags | SSOFlag.SSO_FLAG_ALLOW_TICKETS | SSOFlag.SSO_FLAG_VALIDATE_TICKETS; } if (local) { flags = flags | SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL; } // Create the application ISSOAdmin ssoAdmin = new ISSOAdmin(); ssoAdmin.CreateApplication(application, description, contact, userGroup, adminGroup, flags, fields); // Create fields used by the application flags = 0; ssoAdmin.CreateFieldInfo(application, "User ID", flags); flags = SSOFlag.SSO_FLAG_FIELD_INFO_MASK | SSOFlag.SSO_FLAG_FIELD_INFO_SYNC; ssoAdmin.CreateFieldInfo(application, "Password", flags); // Enable the application ssoAdmin.UpdateApplication(application, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); } catch (Exception e) { throw new Exception("Failed to create affiliate application " + application + ". " + e.Message); } }
// Borrowed largely from Jon Flanders' SSOAppConfigHelper object. internal static void CreateApp(string appName, string userGroup, string adminGroup) { const int Fields = 2; int flags = SSOFlag.SSO_FLAG_APP_CONFIG_STORE | SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL | SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL; ISSOAdmin _ssoAdmin = new ISSOAdmin(); _ssoAdmin.CreateApplication( appName, appName + " Configuration Data", "*****@*****.**", userGroup, adminGroup, flags, Fields); _ssoAdmin.CreateFieldInfo(appName, "*****@*****.**", SSOFlag.SSO_FLAG_NONE); _ssoAdmin.CreateFieldInfo(appName, PropName, SSOFlag.SSO_FLAG_NONE); _ssoAdmin.UpdateApplication(appName, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); }
private void save(string name) { SSOPropBag propertiesBag = new SSOPropBag(); ISSOAdmin a = new ISSOAdmin(); string appUserAcct, appAdminAcct, description, contactInfo; HybridDictionary props = SSOConfigManager.GetConfigProperties(tvApps.SelectedNode.Text, out description, out contactInfo, out appUserAcct, out appAdminAcct); foreach (DataGridViewRow row in dgvSearch.Rows) { if (row.Cells[0].Value != null) { if (row.Cells[1].Value == null) { MessageBox.Show("The key value cannot be blank!", "Blank key value", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //set values string propName = row.Cells[0].Value.ToString(); object objPropValue = row.Cells[1].Value; propertiesBag.Write(propName, ref objPropValue); if (!props.Contains(propName)) { a.CreateFieldInfo(tvApps.SelectedNode.Text, propName, 0); } } } a.UpdateApplication(tvApps.SelectedNode.Text, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); try { SSOConfigManager.SetConfigProperties(tvApps.SelectedNode.Text, propertiesBag); MessageBox.Show("Properties saved successfully.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show("Error Occured. Details: " + ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void CreateConfigStoreApplication(string appName, string description, string uAccountName, string adminAccountName, SSOPropBag propertiesBag, ArrayList maskArray) { int flags1 = 0 | 1048576 | 4 | 262144; ISSOAdmin ssoAdmin = (ISSOAdmin) new SSOAdmin(); ssoAdmin.CreateApplication(appName, description, "", uAccountName, adminAccountName, flags1, propertiesBag.PropertyCount); int index = 0; ssoAdmin.CreateFieldInfo(appName, "dummy", 0); foreach (DictionaryEntry property in propertiesBag.properties) { string label = property.Key.ToString(); int flags2 = 0 | Convert.ToInt32(maskArray[index]); ssoAdmin.CreateFieldInfo(appName, label, flags2); ++index; } ssoAdmin.UpdateApplication(appName, (string)null, (string)null, (string)null, (string)null, 2, 2); }
public static AffiliateApplication Create( string name, string userGroup = DEFAULT_USER_GROUP_NAME, string administratorGroup = DEFAULT_ADMINISTRATOR_GROUP_NAME, string description = null ) { if (name.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(name)); } if (name.Contains(' ')) { throw new ArgumentException("Name cannot contain spaces.", nameof(name)); } if (FindByName(name) != null) { throw new ArgumentException($"{nameof(AffiliateApplication)} '{name}' already exists and cannot be duplicated.", nameof(name)); } var application = new AffiliateApplication { Name = name, AdministratorGroup = administratorGroup ?? DEFAULT_ADMINISTRATOR_GROUP_NAME, Contact = DEFAULT_CONTACT_INFO, Description = description ?? $"{name} Configuration Store", UserGroup = userGroup ?? DEFAULT_USER_GROUP_NAME }; var ssoAdmin = new ISSOAdmin(); ssoAdmin.CreateApplication( application.Name, application.Description, application.Contact, application.UserGroup, application.AdministratorGroup, SSOFlag.SSO_FLAG_APP_CONFIG_STORE | SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL | SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL, 1); ssoAdmin.CreateFieldInfo(name, application.Contact, SSOFlag.SSO_FLAG_NONE); ssoAdmin.UpdateApplication(name, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); return(application); }
public static AffiliateApplication Create( string name, string[] administratorGroups = null, string[] userGroups = null, string description = null) { if (name.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(name)); } if (name.Contains(' ')) { throw new ArgumentException("Name cannot contain spaces.", nameof(name)); } if (FindByName(name) != null) { throw new ArgumentException($"{nameof(AffiliateApplication)} '{name}' already exists and cannot be duplicated.", nameof(name)); } var application = new AffiliateApplication { Name = name, AdministratorGroups = administratorGroups ?? DefaultAdministratorGroups, Contact = DEFAULT_CONTACT_INFO, Description = description ?? $"{name} Configuration Store", UserGroups = userGroups ?? DefaultUserGroups }; var ssoAdmin = new ISSOAdmin(); ssoAdmin.CreateApplication( application.Name, application.Description, application.Contact, application.UserGroups.JoinGroups(), application.AdministratorGroups.JoinGroups(), SSOFlag.SSO_FLAG_APP_CONFIG_STORE | SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL | SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL, 2 /* number of fields to be created */); ssoAdmin.CreateFieldInfo(name, application.Contact, SSOFlag.SSO_FLAG_NONE); ssoAdmin.CreateFieldInfo(name, DEFAULT_SETTINGS_KEY, SSOFlag.SSO_FLAG_NONE); ssoAdmin.UpdateApplication(name, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); return(application); }
/// <summary> /// execute task /// </summary> /// <returns></returns> public override bool Execute() { var fieldNames = CommaDelimitedFieldNames.Split(",".ToCharArray()); var noFields = fieldNames.Length + 1; var appFlags = 0; //bitwise operation for flags appFlags |= SSOFlag.SSO_FLAG_APP_CONFIG_STORE; appFlags |= SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL; appFlags |= SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL; var admin = new ISSOAdmin(); admin.CreateApplication(ApplicationName, Description, "", UserGroup, AdministratorGroup, appFlags, noFields); const int fieldFlags = 0; admin.CreateFieldInfo(ApplicationName, "Reserved", fieldFlags); foreach (var fieldName in fieldNames) { admin.CreateFieldInfo(ApplicationName, fieldName, fieldFlags); } admin.UpdateApplication(ApplicationName, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); var propertiesBag = new ConfigurationPropertyBag(); foreach (var field in fieldNames) { object val = "<empty>"; propertiesBag.Write(field, ref val); } SSOConfiguration.Write(ApplicationName, propertiesBag); return(true); }