[python-ldap] Read/Change public ssh key with ldap-python

John Theodore JohnTheodore42 at gmail.com
Mon Aug 18 18:44:10 CEST 2014


I'm trying to make a simple web app that can manage/change my public ssh
keys on ldap using python-ldap and django. I'm trying to understand the
ldap library better. I know I can query the ldap box and get a list of
attributes (including public ssh keys) by doing this command:

l=ldap.initialize("ldap://myldaphost.mydomain.com")
l.simple_bind_s("CN=ldapuser,CN=Users,DC=mydomain, DC=com","secret")
r = l.search_s(
"CN=ANYCOMPUTER,CN=Computers,DC=mydomain,DC=co m",
ldap.SCOPE_SUBTREE, # this is the default of ldapsearch
"(objectClass=*)"
)

.
What I'm trying to figure out, is how can I delete or update an ssh key for
a specific account? The command I would be doing on ldapmodify is this:

ldapmodify -h localhost -D "uid=user,ou=People,dc=mgmt,dc=symcpe,dc=net" -w
$passwrd -f /tmp/usertomod.ldif.

How can I duplicate this command in python-ldap?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20140818/935faa25/attachment.html>


More information about the python-ldap mailing list