tampakrap/django-ldapdb — pull request #3 by mgorny (2013-08-14 08:33:24+00:00)
Title: Support for bind_as()

Please review.

You can use it like:

m=LDAPUser.objects.get(username='m')
m.password=['2345']
m.bind_as(alias='ldap-user', password='1234').save()

or, more cleaner:

m=LDAPUser.objects.get(username='m').bind_as(alias='ldap-user', password='1234')
m.password=['2345']
m.save()

or for admin:

m=LDAPUser.objects.get(username='m').bind_as(alias='ldap-admin', dn='...', password='...')
m.password=['2345']
m.save()

*alias* is a free-form string that will be used in `settings.DATABASES`. It is important that it is unique for credentials since previous alias is reused without checking `dn` and `password`.

*dn* specifies DN to use. If unspecified, defaults to DN of current object.