def get_or_create_user(self, username, ldap_user):
model = self.get_user_model()<EOL>username_field = getattr(model, '<STR_LIT>', '<STR_LIT:username>')<EOL>kwargs = {<EOL>username_field + '<STR_LIT>': username,<EOL>'<STR_LIT>': {username_field: username.lower()}<EOL>}<EOL>return model.objects.get_or_create(**kwargs)<EOL>
This must return a (User, created) 2-tuple for the given LDAP user.
username is the Django-friendly username of the user. ldap_user.dn is
the user's DN and ldap_user.attrs contains all of their LDAP attributes.