]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/modrdn.c
fix for select_backend suggested G. Gombas (ITS 1090)
[openldap] / servers / slapd / back-ldap / modrdn.c
index fd54b36aa24c6732a1580ef27348d43ceaca2e9c..66761c0a739de37d0b3b3ec03a9863cd63f4fe8f 100644 (file)
  *    ever read sources, credits should appear in the documentation.
  * 
  * 4. This notice may not be removed or altered.
+ *
+ *
+ *
+ * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
+ * 
+ * This software is being modified by Pierangelo Masarati.
+ * The previously reported conditions apply to the modified code as well.
+ * Changes in the original code are highlighted where required.
+ * Credits for the original code go to the author, Howard Chu.
  */
 
 #include "portable.h"
@@ -51,21 +60,37 @@ ldap_back_modrdn(
        struct ldapinfo *li = (struct ldapinfo *) be->be_private;
        struct ldapconn *lc;
 
+       char *mdn, *mnewSuperior;
+
        lc = ldap_back_getconn( li, conn, op );
-       if (!lc)
+       if ( !lc ) {
                return( -1 );
+       }
 
        if (newSuperior) {
                int version = LDAP_VERSION3;
                ldap_set_option( lc->ld, LDAP_OPT_PROTOCOL_VERSION, &version);
+               
+               mnewSuperior = ldap_back_dn_massage( li,
+                       ch_strdup( newSuperior ), 0 );
+               if ( mnewSuperior == NULL ) {
+                       return( -1 );
+               }
        }
 
-       if (!lc->bound) {
-               ldap_back_dobind(lc, op);
-               if (!lc->bound)
-                       return( -1 );
+       if ( !ldap_back_dobind(lc, op) ) {
+               return( -1 );
        }
 
-       ldap_rename2_s( lc->ld, dn, newrdn, newSuperior, deleteoldrdn );
+       mdn = ldap_back_dn_massage( li, ch_strdup( dn ), 0 );
+       if ( mdn == NULL ) {
+               return( -1 );
+       }
+
+       ldap_rename2_s( lc->ld, mdn, newrdn, mnewSuperior, deleteoldrdn );
+
+       free( mdn );
+       if ( mnewSuperior ) free( mnewSuperior );
+       
        return( ldap_back_op_result( lc, op ) );
 }