<div dir="ltr">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: <div>

<br></div><div><span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">l=ldap.initialize("ldap://<a href="http://myldaphost.mydomain.com">myldaphost.mydomain.com</a>")</span><br style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">

<span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">l.simple_bind_s("CN=ldapuser,CN=Users,DC=mydomain, DC=com","secret")</span><br style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">

<span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">r = l.search_s(</span><br style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">"CN=ANYCOMPUTER,CN=Computers,DC=mydomain,DC=co m",</span><br style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">

<span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">ldap.SCOPE_SUBTREE, # this is the default of ldapsearch</span><br style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">

<span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">"(objectClass=*)"</span><br style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">)</span><br>

</div><div><span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">.</span></div>

<div><span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px">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:</span></div>

<div><span style="color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:14px;line-height:20px"><br></span></div><div><font color="#000000" face="Arial, sans-serif"><span style="font-size:14px;line-height:20px">ldapmodify -h localhost -D "uid=user,ou=People,dc=mgmt,dc=symcpe,dc=net" -w $passwrd -f /tmp/usertomod.ldif.</span></font><br>

</div><div><font color="#000000" face="Arial, sans-serif"><span style="font-size:14px;line-height:20px"><br></span></font></div><div><font color="#000000" face="Arial, sans-serif"><span style="font-size:14px;line-height:20px">How can I duplicate this command in python-ldap?</span></font></div>

</div>