Populate the given profile object flags from AUTH_LDAP_PROFILE_FLAGS_BY_DN_REGEX.
        Returns True if the profile was modified

def _populate_profile_flags_from_dn_regex(self, profile):
        """
        Populate the given profile object flags from AUTH_LDAP_PROFILE_FLAGS_BY_DN_REGEX.
        Returns True if the profile was modified
        """
        save_profile = True
        for field, regex in self.settings.PROFILE_FLAGS_BY_DN_REGEX.items():
            field_value = False
            if re.search(regex, self._get_user_dn(), re.IGNORECASE):
                field_value = True
            setattr(profile, field, field_value)
            save_profile = True

        return save_profile