Reputation: 3104
I know how to modify an attribute.
c.modify('cn=user1,ou=users,o=company',
{'userWorkstations': [(MODIFY_REPLACE, ['Win-7'])]})
This link shows how to delete an entry.
But How to delete an attribute(example:'userWorkstations'
) of user in ldap ?
Upvotes: 2
Views: 3675
Reputation: 71
As Giovanni said in a comment:
in ldap3: c.modify('cn=user1,ou=users,o=company', {'userWorkstations': [(MODIFY_DELETE, ['Win-7'])]}) – cannatag Jul 3 '16 at 15:22
I just wanted to point out that also in ldap3 there is a ORM style interaction with LDAP and that would look slightly different:
UserObj.userWorkstations -= 'Win-7'
or to remove the attribute no matter what values it may have:
UserObj.userWorkstations.remove()
And after changes commit it back to LDAP: UserObj.entry_commit_changes()
It is left as an exercise to create UserObj as a Writer object suitable for making these calls.
Upvotes: 1
Reputation: 10996
An LDAP Modify Request has various "Modification Types" that may be performed.
You can "ADD" a value of an attribute. You can "DELETE" a value of an attribute. You can "REPLACE" a value of an attribute. You can "INCREMENT" a value of an attribute. (integer Types only)
If the modification type is "delete" and there is an attribute description without any values, then all values for the specified attribute will be removed from the entry. Under normal circumstances, a modify operation cannot be used with the delete modification type to remove an attribute that does not already exist (although the "replace" modification type can be used to accomplish this).
The precise programing language may have API simplification of these Modification Types.
Upvotes: 3