From 5109f9d29b407f54067ac8351a5ba3259159d44c Mon Sep 17 00:00:00 2001 From: jlaine Date: Mon, 24 May 2010 07:03:48 +0000 Subject: [PATCH] add some examples git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@855 e071eeec-0327-468d-9b6a-08194a12b294 --- examples/__init__.py | 0 examples/models.py | 54 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 examples/__init__.py create mode 100644 examples/models.py diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/examples/models.py b/examples/models.py new file mode 100644 index 0000000..9144798 --- /dev/null +++ b/examples/models.py @@ -0,0 +1,54 @@ +from ldapdb.models.fields import CharField, IntegerField, ListField +import ldapdb.models + +class LdapUser(ldapdb.models.Model): + """ + Class for representing an LDAP user entry. + """ + # LDAP meta-data + base_dn = "ou=people,dc=nodomain" + object_classes = ['posixAccount', 'shadowAccount', 'inetOrgPerson'] + + # inetOrgPerson + first_name = CharField(db_column='givenName') + last_name = CharField(db_column='sn') + full_name = CharField(db_column='cn') + email = CharField(db_column='mail') + phone = CharField(db_column='telephoneNumber', blank=True) + mobile_phone = CharField(db_column='mobile', blank=True) + photo = ImageField(db_column='jpegPhoto') + + # posixAccount + uid = IntegerField(db_column='uidNumber', unique=True) + group = IntegerField(db_column='gidNumber') + gecos = CharField(db_column='gecos') + home_directory = CharField(db_column='homeDirectory') + login_shell = CharField(db_column='loginShell', default=USERS_SHELL) + username = CharField(db_column='uid', primary_key=True) + password = CharField(db_column='userPassword') + + def __str__(self): + return self.username + + def __unicode__(self): + return self.full_name + +class LdapGroup(ldapdb.models.Model): + """ + Class for representing an LDAP group entry. + """ + # LDAP meta-data + base_dn = "ou=groups,dc=nodomain" + object_classes = ['posixGroup'] + + # posixGroup attributes + gid = IntegerField(db_column='gidNumber', unique=True) + name = CharField(db_column='cn', max_length=200, primary_key=True) + members = ListField(db_column='memberUid') + + def __str__(self): + return self.name + + def __unicode__(self): + return self.name + -- 2.30.2