Parcourir la source

Use unicode instead of bytes in ldap

python-ldap >= 3.0 use unicode to be compatible with python3
Grégoire Jadi il y a 6 ans
Parent
commit
b105337f2d
2 fichiers modifiés avec 23 ajouts et 23 suppressions
  1. 18 18
      coin/members/models.py
  2. 5 5
      coin/settings_local.example-illyse.py

+ 18 - 18
coin/members/models.py

@@ -466,27 +466,27 @@ class MembershipFee(models.Model):
 class LdapUser(ldapdb.models.Model):
     # "ou=users,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
     base_dn = settings.LDAP_USER_BASE_DN
-    object_classes = [b'inetOrgPerson', b'organizationalPerson', b'person',
-                      b'top', b'posixAccount', b'ldapPublicKey']
+    object_classes = ['inetOrgPerson', 'organizationalPerson', 'person',
+                      'top', 'posixAccount', 'ldapPublicKey']
 
-    uid = CharField(db_column=b'uid', unique=True, max_length=255)
-    nick_name = CharField(db_column=b'cn', unique=True, primary_key=True,
+    uid = CharField(db_column='uid', unique=True, max_length=255)
+    nick_name = CharField(db_column='cn', unique=True, primary_key=True,
                           max_length=255)
-    first_name = CharField(db_column=b'givenName', max_length=255)
-    last_name = CharField(db_column=b'sn', max_length=255)
-    display_name = CharField(db_column=b'displayName', max_length=255,
+    first_name = CharField(db_column='givenName', max_length=255)
+    last_name = CharField(db_column='sn', max_length=255)
+    display_name = CharField(db_column='displayName', max_length=255,
                              blank=True)
-    password = CharField(db_column=b'userPassword', max_length=255)
-    uidNumber = IntegerField(db_column=b'uidNumber', unique=True)
-    gidNumber = IntegerField(db_column=b'gidNumber', default=2000)
+    password = CharField(db_column='userPassword', max_length=255)
+    uidNumber = IntegerField(db_column='uidNumber', unique=True)
+    gidNumber = IntegerField(db_column='gidNumber', default=2000)
     # Used by Sympa for logging in.
-    mail = CharField(db_column=b'mail', max_length=255, blank=True,
+    mail = CharField(db_column='mail', max_length=255, blank=True,
                      unique=True)
-    homeDirectory = CharField(db_column=b'homeDirectory', max_length=255,
+    homeDirectory = CharField(db_column='homeDirectory', max_length=255,
                               default='/tmp')
-    loginShell = CharField(db_column=b'loginShell', max_length=255,
+    loginShell = CharField(db_column='loginShell', max_length=255,
                               default='/bin/bash')
-    sshPublicKey = ListField(db_column=b'sshPublicKey', default=[])
+    sshPublicKey = ListField(db_column='sshPublicKey', default=[])
 
     def __unicode__(self):
         return self.display_name
@@ -498,11 +498,11 @@ class LdapUser(ldapdb.models.Model):
 # class LdapGroup(ldapdb.models.Model):
 # "ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
 #     base_dn = settings.LDAP_GROUP_BASE_DN
-#     object_classes = [b'posixGroup']
+#     object_classes = ['posixGroup']
 
-#     gid = IntegerField(db_column=b'gidNumber', unique=True)
-#     name = CharField(db_column=b'cn', max_length=200, primary_key=True)
-#     members = ListField(db_column=b'memberUid')
+#     gid = IntegerField(db_column='gidNumber', unique=True)
+#     name = CharField(db_column='cn', max_length=200, primary_key=True)
+#     members = ListField(db_column='memberUid')
 
 #     def __unicode__(self):
 #         return self.name

+ 5 - 5
coin/settings_local.example-illyse.py

@@ -29,15 +29,15 @@ DATABASES = {
         'ENGINE': 'ldapdb.backends.ldap',
         'NAME': 'ldap://ldapdev.illyse.org:389/',
         'TLS': True,
-        'USER': 'cn=illysedev,ou=services,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR',
-        'PASSWORD': 'gfj83-E8ECgGh23JK_Ol12'
+        'USER': u'cn=illysedev,ou=services,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR',
+        'PASSWORD': u'gfj83-E8ECgGh23JK_Ol12'
     }
 }
 
 # LDAP Base DNs
-LDAP_USER_BASE_DN = "ou=users,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
-LDAP_GROUP_BASE_DN = "ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
-VPN_CONF_BASE_DN = "ou=vpn,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
+LDAP_USER_BASE_DN = u'ou=users,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR'
+LDAP_GROUP_BASE_DN = u'ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR'
+VPN_CONF_BASE_DN = u'ou=vpn,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR'
 
 # First UID to use for users
 LDAP_USER_FIRST_UID = 2000