[Date Prev][Date Next] [Chronological] [Thread] [Top]

Permissive modify and LDAP_MOD_INCREMENT



What do you think of allowing permissive modify to allow an initial
value to be set in the case LDAP_MOD_INCREMENT is used on a missing
attribute? This is the only way to atomically set an initial value
if it can't be done at provisioning time.

Index: mods.c
===================================================================
RCS file: /repo/OpenLDAP/pkg/ldap/servers/slapd/mods.c,v
retrieving revision 1.58
diff -u -r1.58 mods.c
--- mods.c      3 Jan 2006 22:12:14 -0000       1.58
+++ mods.c      14 Jan 2006 18:15:21 -0000
@@ -377,11 +377,19 @@

        a = attr_find( e->e_attrs, mod->sm_desc );
        if( a == NULL ) {
-               *text = textbuf;
-               snprintf( textbuf, textlen,
-                       "modify/increment: %s: no such attribute",
-                       mod->sm_desc->ad_cname.bv_val );
-               return LDAP_NO_SUCH_ATTRIBUTE;
+               if ( permissive ) {
+                       Modification modReplace = *mod;
+
+                       modReplace.sm_op = LDAP_MOD_REPLACE;
+
+                       return modify_add_values(e, &modReplace, permissive, text, textbuf, textlen);
+               } else {
+                       *text = textbuf;
+                       snprintf( textbuf, textlen,
+                               "modify/increment: %s: no such attribute",
+                               mod->sm_desc->ad_cname.bv_val );
+                       return LDAP_NO_SUCH_ATTRIBUTE;
+               }
        }

        if ( !strcmp( a->a_desc->ad_type->sat_syntax_oid, SLAPD_INTEGER_SYNTAX )) {

-- Luke

--