[python-ldap] ldap.modlist.modifyModlist

Clayborn, Jared Jared.Clayborn at oa.mo.gov
Wed Nov 26 15:45:26 CET 2014


I have a system setup and I want to be able to remove users from a group. the group format is

dn: cn=group1,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn=group1
userpassword::secret
gidNumber: 123
memberUid: member1
...
memberUid: member10


I have the following code to delete a user from the group, but it deletes the entire list

#/usr/bin/python
Import ldap
Import ldap.modlist as modlist

l = ldap.initialize("ldap://localhost:389/")
l.simple_bind_s("cn=admin,dc=example,dc=com","secret")
#delete from which group
GRP = raw_input('Name of group deleting from: ')

dn = 'cn='+GRP+',ou=Group,dc=example,dc=com'
#get member to delete
delMember = raw_input('Member uid to delete: ')

old = {'memberUid':delMember}
new={'':''}

#should replace the member name with a blank
ldif = modlist.modifModlist(old,new)
l.modify_s(dn,ldif)

l.unbind_s()


I have tried multiple configurations for the old/new dicts and even modlist.modifyModlist(old,new,ignore_oldexistant=1) to no avail.
Any help would be greatly appreciated.  Thanks

Jared Clayborn
Information Technologist I
OA/ITSD - WMASS
Phone: 573-522-6364
E-Mail: Jared Clayborn<mailto:jared.clayborn at oa.mo.gov>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20141126/53b58d04/attachment.html>


More information about the python-ldap mailing list