def create_ldap_user(self, ldap_user):
    dn = (('uid=%s,' % ldap_user.name) + self.user_base_dn)
    data = modlist.addModlist(self._unicode_to_string(ldap_user.attributes))
    try:
        self.client.add_s(dn, data)
    except ldap.LDAPError as e:
        six.reraise(LDAPBackendError, e)
    else:
        ldap_user.backend_id = dn
        ldap_user.save(update_fields=['backend_id'])
def create_ldap_user(self, ldap_user):
    dn = (('uid=%s,' % ldap_user.name) + self.user_base_dn)
    data = modlist.addModlist(self._unicode_to_string(ldap_user.attributes))
    try:
        self.client.add_s(dn, data)
    except ldap.LDAPError as e:
        six.reraise(LDAPBackendError, e)
    else:
        ldap_user.backend_id = dn
        ldap_user.save(update_fields=['backend_id'])