]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/extended.c
Free IDL_CACHE locks
[openldap] / servers / slapd / back-ldap / extended.c
index 47a1f1b6c5a16b31725787bac8d2f850831e1564..5a8b7535b3f5ce12746f493fb8241c3e951e6def 100644 (file)
@@ -26,48 +26,27 @@ static struct exop {
 
 int
 ldap_back_extended(
-       Backend         *be,
-       Connection              *conn,
        Operation               *op,
-       struct berval           *reqoid,
-       struct berval   *reqdata,
-       char            **rspoid,
-       struct berval   **rspdata,
-       LDAPControl *** rspctrls,
-       const char**    text,
-       BerVarray       *refs 
-)
+       SlapReply               *rs )
 {
        int i;
 
        for( i=0; exop_table[i].extended != NULL; i++ ) {
-               if( ber_bvcmp( exop_table[i].oid, reqoid ) == 0 ) {
-                       return (exop_table[i].extended)(
-                               be, conn, op,
-                               reqoid, reqdata,
-                               rspoid, rspdata, rspctrls,
-                               text, refs );
+               if( ber_bvcmp( exop_table[i].oid, &op->oq_extended.rs_reqoid ) == 0 ) {
+                       return (exop_table[i].extended)( op, rs );
                }
        }
 
-       *text = "not supported within naming context";
+       rs->sr_text = "not supported within naming context";
        return LDAP_UNWILLING_TO_PERFORM;
 }
 
 int
 ldap_back_exop_passwd(
-       Backend         *be,
-       Connection              *conn,
        Operation               *op,
-       struct berval           *reqoid,
-       struct berval   *reqdata,
-       char                    **rspoid,
-       struct berval   **rspdata,
-       LDAPControl             *** rspctrls,
-       const char              **text,
-       BerVarray *refs )
+       SlapReply               *rs )
 {
-       struct ldapinfo *li = (struct ldapinfo *) be->be_private;
+       struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
        struct ldapconn *lc;
        struct berval id = { 0, NULL };
        struct berval old = { 0, NULL };
@@ -75,15 +54,15 @@ ldap_back_exop_passwd(
        struct berval dn, mdn = { 0, NULL }, newpw;
        LDAPMessage *res;
        ber_int_t msgid;
-       char *msg = NULL, *match = NULL;
        int rc;
+       dncookie dc;
 
-       lc = ldap_back_getconn(li, conn, op);
-       if (!lc || !ldap_back_dobind(li, lc, conn, op) ) {
+       lc = ldap_back_getconn(op, rs);
+       if (!lc || !ldap_back_dobind(lc, op, rs) ) {
                return -1;
        }
 
-       rc = slap_passwd_parse( reqdata, &id, &old, &new, text );
+       rc = slap_passwd_parse( op->oq_extended.rs_reqdata, &id, &old, &new, &rs->sr_text );
        if (rc != LDAP_SUCCESS)
                return rc;
        
@@ -102,47 +81,32 @@ ldap_back_exop_passwd(
 #endif
 
        if (dn.bv_len == 0) {
-               *text = "No password is associated with the Root DSE";
+               rs->sr_text = "No password is associated with the Root DSE";
                return LDAP_UNWILLING_TO_PERFORM;
        }
        if (id.bv_len) {
+               dc.rwmap = &li->rwmap;
 #ifdef ENABLE_REWRITE
-               switch ( rewrite_session( li->rwinfo, "modifyPwd", dn.bv_val, conn, &mdn.bv_val ) ) {
-               case REWRITE_REGEXEC_OK:
-                       if ( mdn.bv_val == NULL ) {
-                               mdn.bv_val = dn.bv_val;
-                       }
-                       mdn.bv_len = strlen(mdn.bv_val);
-#ifdef NEW_LOGGING
-                       LDAP_LOG( BACK_LDAP, DETAIL1,
-                               "[rw] modifyPwd: \"%s\" -> \"%s\"\n", dn.bv_val, mdn.bv_val, 0 );
-#else /* !NEW_LOGGING */
-                       Debug( LDAP_DEBUG_ARGS, "rw> modifyPwd: \"%s\" -> \"%s\"\n%s",
-                                       dn.bv_val, mdn.bv_val, "" );
-#endif /* !NEW_LOGGING */
-                       break;
-
-               case REWRITE_REGEXEC_UNWILLING:
-                       send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM,
-                                       NULL, "Operation not allowed", NULL, NULL );
-                       return( -1 );
-
-               case REWRITE_REGEXEC_ERR:
-                       send_ldap_result( conn, op, LDAP_OTHER,
-                                       NULL, "Rewrite error", NULL, NULL );
-                       return( -1 );
+               dc.conn = op->o_conn;
+               dc.rs = rs;
+               dc.ctx = "modifyPwd";
+#else
+               dc.tofrom = 1;
+               dc.normalized = 0;
+#endif
+               if ( ldap_back_dn_massage( &dc, &dn, &mdn ) ) {
+                       send_ldap_result( op, rs );
+                       return -1;
                }
-#else /* !ENABLE_REWRITE */
-               ldap_back_dn_massage( li, &dn, &mdn, 0, 1 );
-#endif /* !ENABLE_REWRITE */
        }
 
        rc = ldap_passwd(lc->ld, id.bv_len ? &mdn : NULL, old.bv_len ? &old : NULL,
                new.bv_len ? &new : NULL, op->o_ctrls, NULL, &msgid);
-#ifdef ENABLE_REWRITE
-       if (mdn.bv_val != dn.bv_val)
-#endif
+
+       if (mdn.bv_val != dn.bv_val) {
                free(mdn.bv_val);
+       }
+
        if (rc == LDAP_SUCCESS) {
                if (ldap_result(lc->ld, msgid, 1, NULL, &res) == -1) {
                        ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &rc);
@@ -150,28 +114,30 @@ ldap_back_exop_passwd(
                        /* sigh. parse twice, because parse_passwd doesn't give
                         * us the err / match / msg info.
                         */
-                       int err;
-                       rc = ldap_parse_result(lc->ld, res, &err, &match, &msg,
+                       rc = ldap_parse_result(lc->ld, res, &rs->sr_err, (char **)&rs->sr_matched, (char **)&rs->sr_text,
                                NULL, NULL, 0);
                        if (rc == LDAP_SUCCESS) {
-                               if (err == LDAP_SUCCESS) {
+                               if (rs->sr_err == LDAP_SUCCESS) {
                                        rc = ldap_parse_passwd(lc->ld, res, &newpw);
                                        if (rc == LDAP_SUCCESS && newpw.bv_val) {
-                                               *rspdata = slap_passwd_return(&newpw);
+                                               rs->sr_type = REP_EXTENDED;
+                                               rs->sr_rspdata = slap_passwd_return(&newpw);
                                                free(newpw.bv_val);
                                        }
                                } else {
-                                       rc = err;
+                                       rc = rs->sr_err;
                                }
                        }
                        ldap_msgfree(res);
                }
        }
        if (rc != LDAP_SUCCESS) {
-               rc = ldap_back_map_result(rc);
-               send_ldap_result(conn, op, rc, match, msg, NULL, NULL);
-               if (match) free(match);
-               if (msg) free(msg);
+               rs->sr_err = ldap_back_map_result(rs);
+               send_ldap_result(op, rs);
+               if (rs->sr_matched) free((char *)rs->sr_matched);
+               if (rs->sr_text) free((char *)rs->sr_text);
+               rs->sr_matched = NULL;
+               rs->sr_text = NULL;
                rc = -1;
        }
        return rc;