From: Kurt Zeilenga Date: Sat, 17 Jul 1999 23:06:53 +0000 (+0000) Subject: ldap_modify: delete of last attribute value should delete attribute (ITS#229) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2FOPENLDAP_DEVEL_REFERRALS;p=thirdparty%2Fopenldap.git ldap_modify: delete of last attribute value should delete attribute (ITS#229) --- diff --git a/servers/slapd/back-bdb2/modify.c b/servers/slapd/back-bdb2/modify.c index 6dee5eeace..ab38573dc2 100644 --- a/servers/slapd/back-bdb2/modify.c +++ b/servers/slapd/back-bdb2/modify.c @@ -355,6 +355,17 @@ bdb2i_delete_values( a->a_vals[k - 1] = a->a_vals[k]; } a->a_vals[k - 1] = NULL; + + /* delete the entire attribute, if no values remain */ + if ( a->a_vals[0] == NULL) { + Debug( LDAP_DEBUG_ARGS, + "removing entire attribute %s\n", + mod->mod_type, 0, 0 ); + if ( attr_delete( &e->e_attrs, mod->mod_type ) ) { + return LDAP_NO_SUCH_ATTRIBUTE; + } + } + break; } diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index d9e9b8ed4c..b5fc2c19a9 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -367,6 +367,17 @@ delete_values( a->a_vals[k - 1] = a->a_vals[k]; } a->a_vals[k - 1] = NULL; + + /* delete the entire attribute, if no values remain */ + if ( a->a_vals[0] == NULL) { + Debug( LDAP_DEBUG_ARGS, + "removing entire attribute %s\n", + mod->mod_type, 0, 0 ); + if ( attr_delete( &e->e_attrs, mod->mod_type ) ) { + return LDAP_NO_SUCH_ATTRIBUTE; + } + } + break; }