]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/modrdn.c
SLAPI - Netscape plugin API for slapd - based on patch contributed by Steve Omrani...
[openldap] / servers / slapd / modrdn.c
index be11fdb6e0bb93c300bd9bc69c6ea7b1b77f694d..a4dc8010386b1fb1685f59aaf9cd84ed0150462f 100644 (file)
@@ -29,6 +29,7 @@
  */
 
 #include "portable.h"
+#include "slapi_common.h"
 
 #include <stdio.h>
 
@@ -37,6 +38,7 @@
 
 #include "ldap_pvt.h"
 #include "slap.h"
+#include "slapi.h"
 
 int
 do_modrdn(
@@ -64,6 +66,8 @@ do_modrdn(
        const char *text;
        int manageDSAit;
 
+       Slapi_PBlock *pb = op->o_pb;
+
 #ifdef NEW_LOGGING
        LDAP_LOG( OPERATION, ENTRY, "do_modrdn: begin\n", 0, 0, 0 );
 #else
@@ -201,7 +205,6 @@ do_modrdn(
                        NULL, "cannot rename the root DSE", NULL, NULL );
                goto cleanup;
 
-#ifdef SLAPD_SCHEMA_DN
        } else if ( bvmatch( &ndn, &global_schemandn ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ERR,
@@ -215,7 +218,6 @@ do_modrdn(
                send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
                        NULL, "cannot rename subschema subentry", NULL, NULL );
                goto cleanup;
-#endif
        }
 
        /* FIXME: should have/use rdnPretty / rdnNormalize routines */
@@ -326,6 +328,34 @@ do_modrdn(
        /* deref suffix alias if appropriate */
        suffix_alias( be, &ndn );
 
+#if defined( LDAP_SLAPI )
+       slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
+       slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
+       slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
+       slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+       slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn.bv_val );
+       slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR,
+                       (void *)newSuperior.bv_val );
+       slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
+       slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
+       slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
+
+       rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
+       if ( rc != 0 && rc != LDAP_OTHER ) {
+               /*
+                * either there is no preOp (modrdn) plugins
+                * or a plugin failed. Just log it
+                *
+                * FIXME: is this correct?
+                */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "do_modrdn: modrdn preOps failed\n"));
+#else
+               Debug (LDAP_DEBUG_TRACE, " modrdn preOps failed.\n", 0, 0, 0);
+#endif
+       }
+#endif /* defined( LDAP_SLAPI ) */
+
        /*
         * do the add if 1 && (2 || 3)
         * 1) there is an add function implemented in this backend;
@@ -372,6 +402,23 @@ do_modrdn(
                        NULL, NULL );
        }
 
+#if defined( LDAP_SLAPI )
+       rc = doPluginFNs( be, SLAPI_PLUGIN_POST_MODRDN_FN, pb );
+       if ( rc != 0 && rc != LDAP_OTHER ) {
+               /*
+                * either there is no postOp (modrdn) plugins
+                * or a plugin failed. Just log it
+                *
+                * FIXME: is this correct?
+                */
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_INFO, "do_modrdn: modrdn postOps failed\n"));
+#else
+               Debug (LDAP_DEBUG_TRACE, " modrdn postOps failed.\n", 0, 0, 0);
+#endif
+       }
+#endif /* defined( LDAP_SLAPI ) */
+
 cleanup:
        free( pdn.bv_val );
        free( ndn.bv_val );
@@ -401,9 +448,11 @@ slap_modrdn2mods(
        Modifications   *mod = NULL;
        int             a_cnt, d_cnt;
 
+       assert( new_rdn != NULL );
+       assert( !deleteoldrdn || old_rdn != NULL );
+
        /* Add new attribute values to the entry */
        for ( a_cnt = 0; new_rdn[ 0 ][ a_cnt ]; a_cnt++ ) {
-               int                     rc;
                AttributeDescription    *desc = NULL;
                Modifications           *mod_tmp;
 
@@ -458,7 +507,6 @@ slap_modrdn2mods(
        /* Remove old rdn value if required */
        if ( deleteoldrdn ) {
                for ( d_cnt = 0; old_rdn[ 0 ][ d_cnt ]; d_cnt++ ) {
-                       int                     rc;
                        AttributeDescription    *desc = NULL;
                        Modifications           *mod_tmp;