From 54875619aa432c52e36ccd42b350ecab7f54b147 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 7 Feb 2016 22:40:19 +0100 Subject: [PATCH] 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. --- gvaldap/ldapentities/models.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gvaldap/ldapentities/models.py b/gvaldap/ldapentities/models.py index 0fd72f3..7d0d609 100644 --- a/gvaldap/ldapentities/models.py +++ b/gvaldap/ldapentities/models.py @@ -39,16 +39,16 @@ class LdapGroup(ldapmodels.Model): # LDAP meta-data base_dn = settings.GROUP_BASE_DN #: list of object classes - object_classes = ['posixGroup'] + object_classes = [b'posixGroup'] # posixGroup attributes #: group id (`gidNumber`) - gid = IntegerField(db_column='gidNumber', unique=True) + gid = IntegerField(db_column=b'gidNumber', unique=True) #: 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`) - description = CharField(db_column='description') - members = ListField(db_column='memberUid', blank=True) + description = CharField(db_column=b'description') + members = ListField(db_column=b'memberUid', blank=True) def __str__(self): """ @@ -72,25 +72,25 @@ class LdapUser(ldapmodels.Model): """ base_dn = settings.USER_BASE_DN #: list of object classes - object_classes = ['account', 'posixAccount'] + object_classes = [b'account', b'posixAccount'] # posixAccount #: 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 = IntegerField(db_column='gidNumber') + group = IntegerField(db_column=b'gidNumber') #: GECOS field (`gecos`) - gecos = CharField(db_column='gecos') + gecos = CharField(db_column=b'gecos') #: home directory (`homeDirectory`) - home_directory = CharField(db_column='homeDirectory') + home_directory = CharField(db_column=b'homeDirectory') #: 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`) - 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 = CharField(db_column='userPassword') + password = CharField(db_column=b'userPassword') #: common name (`cn`) - common_name = CharField(db_column='cn') + common_name = CharField(db_column=b'cn') def __str__(self): """