]> git.sur5r.net Git - openldap/commitdiff
Add manage obsolete attributes capability.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 13 May 2005 23:51:43 +0000 (23:51 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 13 May 2005 23:51:43 +0000 (23:51 +0000)
servers/slapd/add.c
servers/slapd/modify.c
servers/slapd/proto-slap.h
servers/slapd/sasl.c
servers/slapd/slapi/slapi_ops.c

index ada140c384376dfa99773559e47136840404144a..77e3dea9dbd1cba13632069bc8f15a18cee0e6b0 100644 (file)
@@ -214,6 +214,8 @@ fe_op_add( Operation *op, SlapReply *rs )
        Modifications   **modtail = &modlist;
        int             rc = 0;
        BackendDB *op_be;
+       char            textbuf[ SLAP_TEXT_BUFLEN ];
+       size_t          textlen = sizeof( textbuf );
 
        manageDSAit = get_manageDSAit( op );
 
@@ -262,6 +264,14 @@ fe_op_add( Operation *op, SlapReply *rs )
                goto done;
        }
 
+       rs->sr_err = slap_mods_no_user_mod_check( op, modlist,
+               &rs->sr_text, textbuf, textlen );
+
+       if ( rs->sr_err != LDAP_SUCCESS ) {
+               send_ldap_result( op, rs );
+               goto done;
+       }
+
 #ifdef LDAP_SLAPI
        if ( op->o_pb ) init_add_pblock( op, &op->o_req_dn, op->ora_e, manageDSAit );
 #endif /* LDAP_SLAPI */
@@ -280,16 +290,13 @@ fe_op_add( Operation *op, SlapReply *rs )
 #endif
                {
                        int             update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
-                       char            textbuf[ SLAP_TEXT_BUFLEN ];
-                       size_t          textlen = sizeof( textbuf );
                        slap_callback   cb = { NULL, slap_replog_cb, NULL, NULL };
 
                        op->o_bd = op_be;
 
                        if ( !update ) {
-                               rs->sr_err = slap_mods_no_update_check( modlist,
-                                               &rs->sr_text,
-                                               textbuf, textlen );
+                               rs->sr_err = slap_mods_no_user_mod_check( op, modlist,
+                                       &rs->sr_text, textbuf, textlen );
 
                                if ( rs->sr_err != LDAP_SUCCESS ) {
                                        send_ldap_result( op, rs );
index f33d3e44b8da184bf26d6e7ffb58647df3947a0f..f468efd38df95a4b1afd46da5a5788f0c8cad923 100644 (file)
@@ -226,6 +226,8 @@ fe_op_modify( Operation *op, SlapReply *rs )
        int             increment = op->orm_increment;
        int             rc = 0;
        BackendDB *op_be;
+       char            textbuf[ SLAP_TEXT_BUFLEN ];
+       size_t          textlen = sizeof( textbuf );
        
        if( op->o_req_ndn.bv_len == 0 ) {
                Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
@@ -348,6 +350,15 @@ fe_op_modify( Operation *op, SlapReply *rs )
                goto cleanup;
        }
 
+       {
+               rs->sr_err = slap_mods_obsolete_check( op, modlist,
+                       &rs->sr_text, textbuf, textlen );
+               if ( rs->sr_err != LDAP_SUCCESS ) {
+                       send_ldap_result( op, rs );
+                       goto cleanup;
+               }
+       }
+
        /* check for modify/increment support */
        if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
@@ -427,15 +438,13 @@ fe_op_modify( Operation *op, SlapReply *rs )
 #endif
                {
                        int             update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
-                       char            textbuf[ SLAP_TEXT_BUFLEN ];
-                       size_t          textlen = sizeof( textbuf );
                        slap_callback   cb = { NULL, slap_replog_cb, NULL, NULL };
 
                        op->o_bd = op_be;
 
                        if ( !update ) {
-                               rs->sr_err = slap_mods_no_update_check( modlist,
-                                               &rs->sr_text, textbuf, textlen );
+                               rs->sr_err = slap_mods_no_user_mod_check( op, modlist,
+                                       &rs->sr_text, textbuf, textlen );
                                if ( rs->sr_err != LDAP_SUCCESS ) {
                                        send_ldap_result( op, rs );
                                        goto cleanup;
@@ -519,10 +528,45 @@ cleanup:;
 }
 
 /*
- * Do non-update constraint checking.
+ * Obsolete constraint checking.
  */
 int
-slap_mods_no_update_check(
+slap_mods_obsolete_check(
+       Operation *op,
+       Modifications *ml,
+       const char **text,
+       char *textbuf,
+       size_t textlen )
+{
+       if( get_manageDIT( op ) ) return LDAP_SUCCESS;
+
+       for ( ; ml != NULL; ml = ml->sml_next ) {
+               if ( is_at_obsolete( ml->sml_desc->ad_type ) &&
+                       (( ml->sml_op != LDAP_MOD_REPLACE &&
+                               ml->sml_op != LDAP_MOD_DELETE ) ||
+                                       ml->sml_values != NULL ))
+               {
+                       /*
+                        * attribute is obsolete,
+                        * only allow replace/delete with no values
+                        */
+                       snprintf( textbuf, textlen,
+                               "%s: attribute is obsolete",
+                               ml->sml_type.bv_val );
+                       *text = textbuf;
+                       return LDAP_CONSTRAINT_VIOLATION;
+               }
+       }
+
+       return LDAP_SUCCESS;
+}
+
+/*
+ * No-user-modification constraint checking.
+ */
+int
+slap_mods_no_user_mod_check(
+       Operation *op,
        Modifications *ml,
        const char **text,
        char *textbuf,
@@ -601,17 +645,6 @@ int slap_mods_check(
                }
 
 #if 0
-               /* moved to slap_mods_no_update_check() */
-               if (!update && is_at_no_user_mod( ad->ad_type )) {
-                       /* user modification disallowed */
-                       snprintf( textbuf, textlen,
-                               "%s: no user modification allowed",
-                               ml->sml_type.bv_val );
-                       *text = textbuf;
-                       return LDAP_CONSTRAINT_VIOLATION;
-               }
-#endif
-
                if ( is_at_obsolete( ad->ad_type ) &&
                        (( ml->sml_op != LDAP_MOD_REPLACE &&
                                ml->sml_op != LDAP_MOD_DELETE ) ||
@@ -627,6 +660,7 @@ int slap_mods_check(
                        *text = textbuf;
                        return LDAP_CONSTRAINT_VIOLATION;
                }
+#endif
 
                if ( ml->sml_op == LDAP_MOD_INCREMENT &&
 #ifdef SLAPD_REAL_SYNTAX
index c8c2095d2f90045ee28942f9ccea103198528ede..cb7bf9fa903867425ea6fe37eab3e63ec2f1e098 100644 (file)
@@ -878,7 +878,14 @@ LDAP_SLAPD_F (int) slap_modrdn2mods(
 /*
  * modify.c
  */
-LDAP_SLAPD_F( int ) slap_mods_no_update_check(
+LDAP_SLAPD_F( int ) slap_mods_obsolete_check(
+       Operation *op,
+       Modifications *ml,
+       const char **text,
+       char *textbuf, size_t textlen );
+
+LDAP_SLAPD_F( int ) slap_mods_no_user_mod_check(
+       Operation *op,
        Modifications *ml,
        const char **text,
        char *textbuf, size_t textlen );
index 091a7d21390a78f0e9351adc76755f85232b5a44..87fce497a5e848222180adb68ecc90b43bb3a21c 100644 (file)
@@ -386,8 +386,8 @@ slap_auxprop_store(
        rc = slap_mods_check( modlist, &text, textbuf, textlen, NULL );
 
        if ( rc == LDAP_SUCCESS ) {
-               rc = slap_mods_no_update_check( modlist, &text,
-                               textbuf, textlen );
+               rc = slap_mods_no_user_mod_check( &op, modlist,
+                       &text, textbuf, textlen );
 
                if ( rc == LDAP_SUCCESS ) {
                        rc = slap_mods_opattrs( &op, modlist, modtail,
index 3e32409ecf40e4adf29a0995d9fdf769ab298acf..5a95c62fc3973a6a9a95a6297e723057dfe86bae 100644 (file)
@@ -455,23 +455,22 @@ slapi_int_ldapmod_to_entry(
                        size_t  textlen = sizeof( textbuf );
 
                        rc = slap_mods_check( modlist, &text, 
-                                       textbuf, textlen, NULL );
+                               textbuf, textlen, NULL );
                        if ( rc != LDAP_SUCCESS) {
                                goto cleanup;
                        }
 
                        if ( !update ) {
-                               rc = slap_mods_no_update_check( modlist,
-                                               &text, textbuf, textlen );
+                               rc = slap_mods_no_user_mod_check( op, modlist,
+                                       &text, textbuf, textlen );
                                if ( rc != LDAP_SUCCESS) {
                                        goto cleanup;
                                }
                        }
 
                        if ( !repl_user ) {
-                               rc = slap_mods_opattrs( op,
-                                               modlist, modtail, &text, 
-                                               textbuf, textlen, 1 );
+                               rc = slap_mods_opattrs( op, modlist, modtail,
+                                       &text, textbuf, textlen, 1 );
                                if ( rc != LDAP_SUCCESS) {
                                        goto cleanup;
                                }
@@ -488,8 +487,7 @@ slapi_int_ldapmod_to_entry(
                }
        }
 
-cleanup:
-
+cleanup:;
        if ( dn.bv_val )
                slapi_ch_free( (void **)&dn.bv_val );
        if ( modlist != NULL )
@@ -1030,14 +1028,14 @@ slapi_modify_internal(
                        slap_callback   cb = { NULL, slap_replog_cb, NULL, NULL };
 
                        rs.sr_err = slap_mods_check( modlist,
-                                       &text, textbuf, textlen, NULL );
+                               &text, textbuf, textlen, NULL );
                        if ( rs.sr_err != LDAP_SUCCESS ) {
                                goto cleanup;
                        }
 
                        if ( !update ) {
-                               rs.sr_err = slap_mods_no_update_check( modlist,
-                                               &text, textbuf, textlen );
+                               rs.sr_err = slap_mods_no_user_mod_check( op, modlist,
+                                       &text, textbuf, textlen );
                                if ( rs.sr_err != LDAP_SUCCESS ) {
                                        goto cleanup;
                                }