Skip to content

Commit

Permalink
Merge remote-tracking branch 'cbleck34/patch-1' into bleeding_edge
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePirateWhoSmellsOfSunflowers committed Aug 14, 2024
2 parents 602308d + 59b3520 commit 41bd967
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions docs/manual/source/tutorial_operations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ Keep in mind that LDAP support a (quite obscure) "multi-rdn" naming option where

Update an entry
===============
To change the attributes of an object you must use the Modify operation. There are three kinds of modifications in LDAP: add, delete and replace.
**Add** is used to add values to an attribute, and creates the attribute if it doesn't exist. **Delete** deletes values from an attribute and if no values are listed, or if all
To change the attributes of an object, you must use the Modify operation. LDAP has three kinds of modifications: add, delete, and replace.
**Add** adds values to an attribute and creates the attribute if it doesn't exist. **Delete** deletes values from an attribute, and if no values are listed or all
current values are listed, remove the entire attribute. **Replace** replaces all existing values of an attribute with some new values, creating the attribute if it
don't already exist. A replace with no value will delete the entire attribute if it exists, and it is ignored if the attribute doesn't exist.
doesn't already exist. A **Replace** with no value will delete the entire attribute if it exists, and it is ignored if the attribute doesn't exist.

The hard part in the Modify operation is that you can mix in a single operation the three kinds of modification for a single entry with one or more attributes
each with one or more values! So the Modify operation syntax is quite complex: you must provide a DN, a dictionary of attributes and for each
attribute a list of modifications where each modification is a tuple with the modification type and the list of values. Let's add a new value to the sn attribute::
each with one or more values! So, the Modify operation syntax is quite complex: you must provide a DN, a dictionary of attributes, and a list of modifications for each attribute; each modification is a tuple with the modification type and the list of values. Let's add a new value to the sn attribute::

>>> from ldap3 import MODIFY_ADD, MODIFY_REPLACE, MODIFY_DELETE
>>> conn.modify('cn=b.smith,ou=moved,ou=ldap3-tutorial,dc=demo1,dc=freeipa,dc=org', {'sn': [(MODIFY_ADD, ['Smyth'])]})
Expand Down

0 comments on commit 41bd967

Please sign in to comment.