public static IEnumerable <AffiliateApplication> FindByContact(string contact = DEFAULT_CONTACT_INFO) { if (contact.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(contact)); } var mapper = new ISSOMapper2(); // https://docs.microsoft.com/en-us/biztalk/core/how-to-change-the-behavior-of-a-single-sign-on-interface var propBag = (IPropertyBag)mapper; object appFilterFlags = (uint)(AffiliateApplicationType.ConfigStore | AffiliateApplicationType.All); propBag.Write("AppFilterFlags", ref appFilterFlags); object appFilterFlagMask = (uint)SSOFlag.SSO_FLAG_APP_FILTER_BY_TYPE; propBag.Write("AppFilterFlagMask", ref appFilterFlagMask); mapper.GetApplications2(out var applications, out var descriptions, out var contacts, out var userAccounts, out var adminAccounts, out _); return(Enumerable.Range(0, applications.Length) .Where(i => contact == ANY_CONTACT_INFO || contacts[i].Equals(contact, StringComparison.OrdinalIgnoreCase)) .Select( i => new AffiliateApplication { Name = applications[i], Description = descriptions[i], Contact = contacts[i], AdministratorGroup = adminAccounts[i], UserGroup = userAccounts[i] })); }
/// <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> /// Loads the Config Store from the Enterprise Single Sign-On (SSO). /// </summary> internal void Load() { try { // provision the dictionary with the names of all the properties that are defined at the affiliate application level var mapper = new ISSOMapper2(); mapper.GetFieldInfo(_affiliateApplicationName, out var labels, out _); // skip contact, which is a dummy 1st field labels.Where(l => l != AffiliateApplication.DEFAULT_CONTACT_INFO).ForEach(l => Properties.Add(l, default)); // populate dictionary with all the property values that have been set var configStore = new ISSOConfigStore(); configStore.GetConfigInfo(_affiliateApplicationName, _identifier, SSOFlag.SSO_FLAG_RUNTIME, this); } catch (COMException exception) when((uint)exception.ErrorCode == (uint)HResult.ErrorMappingNonExistent) { } }
internal ConfigStoreCollection(AffiliateApplication affiliateApplication) { if (affiliateApplication == null) { throw new ArgumentNullException(nameof(affiliateApplication)); } var mapper = new ISSOMapper2(); var applicationMappings = mapper.GetMappingsForExternalUser(affiliateApplication.Name, null); var configStoreIdentifiers = applicationMappings.Cast <ISSOMapping>() .Where(m => m.WindowsDomainName == "$ConfigStore$") .Select(m => m.WindowsUserName) // ensure the default ConfigStore identifier is in the list of configStore's id to instantiate .Union(Enumerable.Repeat(DEFAULT_CONFIG_STORE_IDENTIFIER, affiliateApplication.HasOwnership ? 1 : 0)); _configStoreDictionary = configStoreIdentifiers .Select(id => new ConfigStore(affiliateApplication.Name, id)) .ToDictionary(cs => cs.Identifier); }