Skip to main content

This module provide an easy way to deal with ldap stuff in python.

Project description


This module is actively used on to manage the french python comunity members.

The following examples show all features of the package. If you just want to give it a try in a quickest way read Installation and configuration from the Sphinx documentation.

Get a connection (this custom afpy connection get is configuration from a ~/.ldap.ini file. See Installation and configuration):

>>> from afpy.ldap import custom as ldap
>>> conn = ldap.get_conn()

Get a node via is dn:

>>> dn = 'uid=gawel,ou=members,dc=afpy,dc=org'
>>> node = conn.get_node(dn)
>>> node
<Node at uid=gawel,ou=members,dc=afpy,dc=org>

>>> print node.birthDate

You can also define your own node class with a schema:

>>> from afpy.ldap.node import Node
>>> from afpy.ldap import schema
>>> class User(Node):
...     uid=schema.StringProperty('uid')
...     birthDate = schema.DateProperty('birthDate', title='Date de naissance')
>>> node = conn.get_node(dn, node_class=User)
>>> node
<User at uid=gawel,ou=members,dc=afpy,dc=org>

Then data is converted to a python object:

>>> node.birthDate, 4, 10)

This also allow to generate forms with FormAlchemy:

>>> from afpy.ldap import forms
>>> fs = forms.FieldSet(User)
>>> user = User()
>>> fs.rebind(user)
>>> print fs.render().strip() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
  <label class="field_opt" for="User--uid">Uid</label>
  <input id="User--uid" name="User--uid" type="text" />
  <label class="field_opt" for="User--birthDate">Date de naissance</label>

The source code can be find on the AFPy repository

Got a bug, feature request ? Want to send beer because you love it ? Send an email at or join us on the #afpy channel on freenode.



  • Add ListOfGroups and ListOfPerms attributes. Allow to set user.groups = []


  • fix authentification failure when uid does not exist


  • small fixes
  • add GroupOfUniqueNames


  • Add repoze.what plugins
  • Allow to set node classes via config file
  • fix compat with latest python-ldap


  • require dataflake.ldapconnection>=1.0b1, python-ldap>=2.3.10


  • initial version

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for afpy.ldap, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size afpy.ldap-1.0.tar.gz (34.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page