Populates a User profile object with fields from the LDAP directory.

def _populate_and_save_user_profile(self):
        """
        Populates a User profile object with fields from the LDAP directory.
        """
        try:
            app_label, class_name = django.conf.settings.AUTH_PROFILE_MODULE.split('.')
            profile_model = apps.get_model(app_label, class_name)
            profile, created = profile_model.objects.get_or_create(user=self._user)
            save_profile = False

            logger.debug("Populating Django user profile for %s", get_user_username(self._user))

            save_profile = self._populate_profile_from_attributes(profile) or save_profile
            save_profile = self._populate_profile_flags_from_dn_regex(profile) or save_profile
            save_profile = self._populate_profile_from_group_memberships(profile) or save_profile

            signal_responses = populate_user_profile.send(self.backend.__class__, profile=profile, ldap_user=self)
            if len(signal_responses) > 0:
                save_profile = True

            if save_profile:
                profile.save()
        except ObjectDoesNotExist:
            logger.debug("Django user %s does not have a profile to populate", get_user_username(self._user))
        except LookupError:
            logger.debug('User Profile model defined in settings.AUTH_PROFILE_MODULE is invalid')