public static string[] GetCurrentUserApplications() { if (_applications == null) { ISSOMapper mapper = new ISSOMapper(); AffiliateApplicationType appTypes = AffiliateApplicationType.ConfigStore; IPropertyBag propBag = (IPropertyBag)mapper; uint appFilterFlagMask = SSOFlag.SSO_FLAG_APP_FILTER_BY_TYPE; uint appFilterFlags = (uint)appTypes; object appFilterFlagsObj = appFilterFlags; object appFilterFlagMaskObj = appFilterFlagMask; propBag.Write("AppFilterFlags", ref appFilterFlagsObj); propBag.Write("AppFilterFlagMask", ref appFilterFlagMaskObj); string[] descs; string[] contacts; mapper.GetApplications(out _applications, out descs, out contacts); } return(_applications); }
public static IDictionary <string, string> GetApplications() { ISSOMapper ssoMapper = (ISSOMapper) new SSOMapper(); AffiliateApplicationType affiliateApplicationType = AffiliateApplicationType.ConfigStore; IPropertyBag propertyBag = (IPropertyBag)ssoMapper; uint num = 1; object ptrVar1 = (object)(uint)affiliateApplicationType; object ptrVar2 = (object)num; propertyBag.Write("AppFilterFlags", ref ptrVar1); propertyBag.Write("AppFilterFlagMask", ref ptrVar2); string[] applications = (string[])null; string[] descriptions = (string[])null; string[] contactInfo = (string[])null; ssoMapper.GetApplications(out applications, out descriptions, out contactInfo); Dictionary <string, string> dictionary1 = new Dictionary <string, string>(applications.Length); Dictionary <string, string> dictionary2 = new Dictionary <string, string>(applications.Length); for (int index = 0; index < applications.Length; ++index) { if (applications[index].StartsWith("{")) { dictionary2.Add(applications[index], descriptions[index]); } else { dictionary1.Add(applications[index], descriptions[index]); } } foreach (string key in dictionary2.Keys) { dictionary1.Add(key, dictionary2[key]); } return((IDictionary <string, string>)dictionary1); }
/// <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); } }
/// <summary> /// Returns a list of applications in the SSO store /// </summary> /// <returns>Application names</returns> public static List <string> GetApplications() { //get the app list: string[] applications = null; string[] descs; string[] contacts = null; try { var mapper = new ISSOMapper(); AffiliateApplicationType appTypes = AffiliateApplicationType.ConfigStore; appTypes |= AffiliateApplicationType.All; IPropertyBag propBag = (IPropertyBag)mapper; uint appFilterFlagMask = SSOFlag.SSO_FLAG_APP_FILTER_BY_TYPE; uint appFilterFlags = (uint)appTypes; object appFilterFlagsObj = (object)appFilterFlags; object appFilterFlagMaskObj = (object)appFilterFlagMask; propBag.Write("AppFilterFlags", ref appFilterFlagsObj); propBag.Write("AppFilterFlagMask", ref appFilterFlagMaskObj); mapper.GetApplications(out applications, out descs, out contacts); } catch (COMException comEx) { HandleCOMException(comEx, 0); } List <string> apps = new List <string>(); if (contacts != null) { for (int i = 0; i < applications.Length; i++) { if (string.Equals(contacts[i], ApplicationManager.ContactInfo)) { apps.Add(applications[i]); } } } return(apps); }
private void ManageSSO(Action action, string inputFile) { try { SsoManager ssoManager = new SsoManager(); XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(inputFile); XmlNodeList xnlNodes = xmldoc.SelectNodes("SSOAffiliates/Affiliate"); foreach (XmlNode xndNode in xnlNodes) { XmlElement element = (XmlElement)xndNode; string affiliateName = xndNode.Attributes["name"].Value; if (action == BuildTasks.Action.Remove) { if (ssoManager.Exists(affiliateName)) { ssoManager.Delete(affiliateName); } else { this.Log.LogMessage("SSO Affiliate does not exists '{0}'.", affiliateName); } } else if (action == BuildTasks.Action.Add) { if (ssoManager.Exists(affiliateName)) { this.Log.LogMessage("Application already exists '{0}'.", affiliateName); if (xndNode.ChildNodes.Count > 0) { MapAccounts(xndNode.ChildNodes, ssoManager, affiliateName); } } else { string type = xndNode.Attributes["type"].Value; AffiliateApplicationType affiliateApplicationType = (AffiliateApplicationType)Enum.Parse(typeof(AffiliateApplicationType), type, true); string description = xndNode.Attributes["description"].Value; string contact = xndNode.Attributes["contact"].Value; string userGroup = xndNode.Attributes["adminGroup"].Value; string adminGroup = xndNode.Attributes["userGroup"].Value; bool allowLocal = true; Boolean.TryParse(xndNode.Attributes["allowLocal"].Value, out allowLocal); bool allowTickets = true; Boolean.TryParse(xndNode.Attributes["allowTickets"].Value, out allowTickets); ssoManager.Create(affiliateName, affiliateApplicationType, description, contact, userGroup, adminGroup, allowTickets, allowLocal); this.Log.LogMessage("SSO Affiliate '{0}' Created.", affiliateName); if (xndNode.ChildNodes.Count > 0) { MapAccounts(xndNode.ChildNodes, ssoManager, affiliateName); } } } } } catch (Exception ex) { this.Log.LogMessage("Error while ManageSSOAffiliate. " + ex.ToString()); } }