示例#1
0
        private async Task SyncLdapAttributeToUserField(string userName, List <LdapAuthenticationModeLdapAttributeModel> ldapAttributes, Dictionary <string, string> attributeList)
        {
            var appUser = await userRepository.GetByUsernameAsync(userName, false);

            if (appUser == null)
            {
                throw new ItemNotFoundException($"User with username {userName} could not be found.");
            }

            foreach (LdapAuthenticationModeLdapAttributeModel attributeMapping in ldapAttributes)
            {
                string ldapValue = string.Empty;

                if (attributeList.TryGetValue(attributeMapping.LdapField, out ldapValue))
                {
                    UpdateUserField(appUser, attributeMapping.UserField, ldapValue);
                }
            }

            a3SContext.SaveChanges();
        }