Mark LDAP field names as byte strings

The django-ldapdb code cannot handle unicode field names with real LDAP
directories. This commit marks the field names of LDAP entities as byte
strings.
This commit is contained in:
Jan Dittberner 2016-02-07 22:40:19 +01:00
parent 1a24cf9c50
commit 54875619aa

View file

@ -39,16 +39,16 @@ class LdapGroup(ldapmodels.Model):
# LDAP meta-data # LDAP meta-data
base_dn = settings.GROUP_BASE_DN base_dn = settings.GROUP_BASE_DN
#: list of object classes #: list of object classes
object_classes = ['posixGroup'] object_classes = [b'posixGroup']
# posixGroup attributes # posixGroup attributes
#: group id (`gidNumber`) #: group id (`gidNumber`)
gid = IntegerField(db_column='gidNumber', unique=True) gid = IntegerField(db_column=b'gidNumber', unique=True)
#: group name (`cn`) #: group name (`cn`)
name = CharField(db_column='cn', max_length=200, primary_key=True) name = CharField(db_column=b'cn', max_length=200, primary_key=True)
#: group description (`description`) #: group description (`description`)
description = CharField(db_column='description') description = CharField(db_column=b'description')
members = ListField(db_column='memberUid', blank=True) members = ListField(db_column=b'memberUid', blank=True)
def __str__(self): def __str__(self):
""" """
@ -72,25 +72,25 @@ class LdapUser(ldapmodels.Model):
""" """
base_dn = settings.USER_BASE_DN base_dn = settings.USER_BASE_DN
#: list of object classes #: list of object classes
object_classes = ['account', 'posixAccount'] object_classes = [b'account', b'posixAccount']
# posixAccount # posixAccount
#: user id (`uidNumber`) #: user id (`uidNumber`)
uid = IntegerField(db_column='uidNumber', unique=True) uid = IntegerField(db_column=b'uidNumber', unique=True)
#: group id (`gidNumber`) of the user's primary group #: group id (`gidNumber`) of the user's primary group
group = IntegerField(db_column='gidNumber') group = IntegerField(db_column=b'gidNumber')
#: GECOS field (`gecos`) #: GECOS field (`gecos`)
gecos = CharField(db_column='gecos') gecos = CharField(db_column=b'gecos')
#: home directory (`homeDirectory`) #: home directory (`homeDirectory`)
home_directory = CharField(db_column='homeDirectory') home_directory = CharField(db_column=b'homeDirectory')
#: login shell (`loginShell`) #: login shell (`loginShell`)
login_shell = CharField(db_column='loginShell', default='/bin/bash') login_shell = CharField(db_column=b'loginShell', default='/bin/bash')
#: user name (`uid`) #: user name (`uid`)
username = CharField(db_column='uid', primary_key=True) username = CharField(db_column=b'uid', primary_key=True)
#: password (`userPassword`) in an LDAP compatible format #: password (`userPassword`) in an LDAP compatible format
password = CharField(db_column='userPassword') password = CharField(db_column=b'userPassword')
#: common name (`cn`) #: common name (`cn`)
common_name = CharField(db_column='cn') common_name = CharField(db_column=b'cn')
def __str__(self): def __str__(self):
""" """