Search code examples
pythonactive-directoryldapldap-query

How to delete attribute of user in ldap3?


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 ?


Solution

  • 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.