コード例 #1
0
        /// <summary>
        /// Retrieve a service id from a layout action service id.
        /// </summary>
        /// <param name="apis">An ApiList object.</param>
        /// <param name="apiService">A service id.</param>
        /// <returns>A service id.</returns>
        public static string GetApiListService(
            this ApiList apis,
            string apiService)
        {
            if (!apis.IsValid() ||
                !apiService.IsValid())
            {
                return(null);
            }

            return(apis
                   .Where(a => a.GetApiService(apiService) != null)
                   .Select(a => a.GetApiService(apiService))
                   .FirstOrDefault());
        }
コード例 #2
0
        private ApiList <ProfileField> UpdatedProfileFields(Dictionary <string, string> usersSamlTokenProfileData, ApiList <ProfileField> currentProfileFields)
        {
            //get a list of user profile fields with the matching prefix
            var samlProfileFields    = GetSamlProfileFields();
            var updatedProfileFields = new ApiList <ProfileField>();

            bool hasChanges = false;

            foreach (var userProfileField in samlProfileFields)
            {
                try
                {
                    bool userHasField = false;
                    //this checks the current users profile fields against saml (ie remove or update)
                    foreach (var profileField in currentProfileFields.Where(i => i.Label == userProfileField.Name))
                    {
                        //check to see if its in the saml token based on userProfileField name
                        if (!usersSamlTokenProfileData.ContainsKey(userProfileField.Name) && !string.IsNullOrWhiteSpace(profileField.Value))
                        {
                            updatedProfileFields.Add(new ProfileField()
                            {
                                Label = userProfileField.Name, Value = ""
                            });
                            hasChanges = true;
                        }

                        if (usersSamlTokenProfileData.ContainsKey(userProfileField.Name) && profileField.Value != usersSamlTokenProfileData[userProfileField.Name])
                        {
                            updatedProfileFields.Add(new ProfileField()
                            {
                                Label = userProfileField.Name, Value = usersSamlTokenProfileData[userProfileField.Name]
                            });
                            hasChanges = true;
                        }

                        userHasField = true;
                    }

                    //this checks the saml data against the user (ie adding missing entries)
                    if (!userHasField && usersSamlTokenProfileData.ContainsKey(userProfileField.Name))
                    {
                        updatedProfileFields.Add(new ProfileField()
                        {
                            Label = userProfileField.Name, Value = usersSamlTokenProfileData[userProfileField.Name]
                        });
                        hasChanges = true;
                    }
                }
                catch (Exception ex)
                {
                    _eventLogApi.Write("ProfileAttributeManager Error UpdatedProfileFields: " + ex.Message + " : " + ex.StackTrace, new EventLogEntryWriteOptions()
                    {
                        Category = "SAML", EventId = 1, EventType = "Error"
                    });
                }
            }

            if (hasChanges)
            {
                return(updatedProfileFields);
            }
            else
            {
                return(null);
            }
        }