code: def _populate_profile_flags_from_dn_regex(self, profile):
          
          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
docs: Populate the given profile object flags from AUTH_LDAP_PROFILE_FLAGS_BY_DN_REGEX.
          Returns True if the profile was modified