[PATCH] support RFC4525 modify+increment extension
Andreas Hasenack
ahasenack at terra.com.br
Mon Jun 4 23:49:49 CEST 2007
Attached. Simple example:
print "Before:"
print ld.search_s(BASE, ldap.SCOPE_SUBTREE, "(objectClass=sambaUnixIdPool)", ['uidNumber'])
modlist = [(ldap.MOD_INCREMENT, "uidNumber", "1")]
res = ld.modify_s("cn=unixIdPool,dc=example,dc=com", modlist)
print "After:"
print ld.search_s(BASE, ldap.SCOPE_SUBTREE, "(objectClass=sambaUnixIdPool)", ['uidNumber'])
Output:
$ ./modify+increment.py
Before:
[('cn=unixIdPool,dc=example,dc=com', {'uidNumber': ['1042']})]
After:
[('cn=unixIdPool,dc=example,dc=com', {'uidNumber': ['1043']})]
-------------- next part --------------
Index: Modules/constants.c
===================================================================
--- Modules/constants.c
+++ Modules/constants.c 2007-06-04 18:32:18.000000000 -0300
@@ -123,6 +123,7 @@
add_int(d,MOD_ADD);
add_int(d,MOD_DELETE);
add_int(d,MOD_REPLACE);
+ add_int(d,MOD_INCREMENT);
add_int(d,MOD_BVALUES);
add_int(d,MSG_ONE);
Index: Lib/ldap/ldapobject.py
===================================================================
--- Lib/ldap/ldapobject.py
+++ Lib/ldap/ldapobject.py 2007-06-04 18:48:42.000000000 -0300
@@ -310,13 +310,13 @@
dn is the DN of the entry to modify, and modlist is the list
of modifications to make to the entry.
- Each element of the list modlist should be a tuple of the form
- (mod_op,mod_type,mod_vals), where mod_op is the operation (one
- of MOD_ADD, MOD_DELETE, or MOD_REPLACE), mod_type is a string
- indicating the attribute type name, and mod_vals is either
- a string value or a list of string values to add, delete or
- replace respectively. For the delete operation, mod_vals may
- be None indicating that all attributes are to be deleted.
+ Each element of the list modlist should be a tuple of the form
+ (mod_op,mod_type,mod_vals), where mod_op is the operation (one of
+ MOD_ADD, MOD_DELETE, MOD_INCREMENT or MOD_REPLACE), mod_type is a
+ string indicating the attribute type name, and mod_vals is either a
+ string value or a list of string values to add, delete, increment by or
+ replace respectively. For the delete operation, mod_vals may be None
+ indicating that all attributes are to be deleted.
The asynchronous modify() returns the message id of the
initiated request.
More information about the python-ldap
mailing list