def _populate_and_save_user_profile(self):
try:<EOL><INDENT>app_label, class_name = django.conf.settings.AUTH_PROFILE_MODULE.split('<STR_LIT:.>')<EOL>profile_model = apps.get_model(app_label, class_name)<EOL>profile, created = profile_model.objects.get_or_create(user=self._user)<EOL>save_profile = False<EOL>logger.debug("<STR_LIT>", get_user_username(self._user))<EOL>save_profile = self._populate_profile_from_attributes(profile) or save_profile<EOL>save_profile = self._populate_profile_flags_from_dn_regex(profile) or save_profile<EOL>save_profile = self._populate_profile_from_group_memberships(profile) or save_profile<EOL>signal_responses = populate_user_profile.send(self.backend.__class__, profile=profile, ldap_user=self)<EOL>if len(signal_responses) > <NUM_LIT:0>:<EOL><INDENT>save_profile = True<EOL><DEDENT>if save_profile:<EOL><INDENT>profile.save()<EOL><DEDENT><DEDENT>except ObjectDoesNotExist:<EOL><INDENT>logger.debug("<STR_LIT>", get_user_username(self._user))<EOL><DEDENT>except LookupError:<EOL><INDENT>logger.debug('<STR_LIT>')<EOL><DEDENT>
Populates a User profile object with fields from the LDAP directory.