]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapi/slapi_pblock.c
honor '!' (objectClass negation) when checking attribute presence in list
[openldap] / servers / slapd / slapi / slapi_pblock.c
index 6a94a87cc2ce41dfb1aa34c0b7ee4d52ebaa1696..c97880c5f60f8f61c2ed59a50b1e54021998bdb0 100644 (file)
@@ -1,17 +1,26 @@
-/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 2002-2003 The OpenLDAP Foundation.
+ * Portions Copyright 1997,2002-2003 IBM Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
-/*
- * (C) Copyright IBM Corp. 1997,2002
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is 
- * given to IBM Corporation. This software is provided ``as is'' 
- * without express or implied warranty.
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by IBM Corporation for use in
+ * IBM products and subsequently ported to OpenLDAP Software by
+ * Steve Omrani.  Additional significant contributors include:
+ *   Luke Howard
  */
 
 #include "portable.h"
-#include "slapi_common.h"
 #include <slap.h>
 #include <slapi.h>
 
@@ -22,6 +31,10 @@ isOkNetscapeParam( int param )
        case SLAPI_BACKEND:
        case SLAPI_CONNECTION:
        case SLAPI_OPERATION:
+       case SLAPI_OPERATION_PARAMETERS:
+       case SLAPI_OPERATION_TYPE:
+       case SLAPI_OPERATION_ID:
+       case SLAPI_OPERATION_AUTHTYPE:
        case SLAPI_REQUESTOR_ISROOT:
        case SLAPI_BE_MONITORDN:
        case SLAPI_BE_TYPE:
@@ -32,7 +45,16 @@ isOkNetscapeParam( int param )
        case SLAPI_REQUESTOR_DN:
        case SLAPI_REQUESTOR_ISUPDATEDN:
        case SLAPI_CONN_DN:
+       case SLAPI_CONN_CLIENTIP:
+       case SLAPI_CONN_SERVERIP:
        case SLAPI_CONN_AUTHTYPE:
+       case SLAPI_CONN_AUTHMETHOD:
+       case SLAPI_CONN_CERT:
+       case SLAPI_X_CONN_IS_UDP:
+       case SLAPI_X_CONN_CLIENTPATH:
+       case SLAPI_X_CONN_SERVERPATH:
+       case SLAPI_X_CONN_SSF:
+       case SLAPI_X_CONN_SASL_CONTEXT:
        case SLAPI_IBM_CONN_DN_ALT:
        case SLAPI_IBM_CONN_DN_ORIG:
        case SLAPI_IBM_GSSAPI_CONTEXT:
@@ -185,6 +207,12 @@ isOkNetscapeParam( int param )
        case SLAPI_CHANGENUMBER:
        case SLAPI_LOG_OPERATION:
        case SLAPI_DBSIZE:
+       case SLAPI_RESULT_CODE:
+       case SLAPI_RESULT_TEXT:
+       case SLAPI_RESULT_MATCHED:
+       case SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN:
+       case SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN:
+       case SLAPI_PLUGIN_ACL_ALLOW_ACCESS:
                return LDAP_SUCCESS;
        default:
                return INVALID_PARAM;
@@ -249,7 +277,8 @@ static int
 set( Slapi_PBlock *pb, int param, void *val ) 
 {
 #if defined(LDAP_SLAPI)
-       int i;
+       int i, freeit;
+       int addcon = 0;
 
        if ( isValidParam( pb, param ) == INVALID_PARAM ) {
                return PBLOCK_ERROR;
@@ -257,11 +286,27 @@ set( Slapi_PBlock *pb, int param, void *val )
 
        Lock( pb );     
 
-       if ( pb->numParams == MAX_PARAMS ) {
+       if ( pb->numParams == PBLOCK_MAX_PARAMS ) {
                unLock( pb );
                return PBLOCK_ERROR; 
        }
 
+       if ( param == SLAPI_ADD_RESCONTROL ) {
+               addcon = 1;
+               param = SLAPI_RES_CONTROLS;
+       }
+
+       switch ( param ) {
+        case SLAPI_CONN_DN:
+        case SLAPI_CONN_AUTHMETHOD:
+        case SLAPI_IBM_CONN_DN_ALT:
+        case SLAPI_IBM_CONN_DN_ORIG:
+        case SLAPI_RESULT_TEXT:
+        case SLAPI_RESULT_MATCHED:
+               freeit = 1; break;
+       default:
+               freeit = 0; break;
+       }
        for( i = 0; i < pb->numParams; i++ ) { 
                if ( pb->curParams[i] == param ) {
                        break;
@@ -272,7 +317,19 @@ set( Slapi_PBlock *pb, int param, void *val )
                pb->curParams[i] = param;
                pb->numParams++;
        }
-       pb->curVals[i] = val;
+       if ( addcon ) {
+               LDAPControl **ctrls = pb->curVals[i];
+               int j;
+
+               for (j=0; ctrls[j]; j++);
+               ctrls = ch_realloc( ctrls, (j+2)*sizeof(LDAPControl *) );
+               ctrls[j] = val;
+               ctrls[j+1] = NULL;
+               pb->curVals[i] = ctrls;
+       } else {
+               if ( freeit ) ch_free( pb->curVals[i] );
+               pb->curVals[i] = val;
+       }
 
        unLock( pb );   
        return LDAP_SUCCESS;
@@ -350,7 +407,7 @@ slapi_pblock_destroy( Slapi_PBlock* pb )
                str = NULL;
        }
 
-       get( pb, SLAPI_CONN_AUTHTYPE, (void **)&str );
+       get( pb, SLAPI_CONN_AUTHMETHOD, (void **)&str );
        if ( str != NULL ) {
                ch_free( str );
                str = NULL;
@@ -367,6 +424,18 @@ slapi_pblock_destroy( Slapi_PBlock* pb )
                ch_free( str );
        }
 
+       get( pb, SLAPI_RESULT_TEXT, (void **)&str );
+       if ( str != NULL ) {
+               ch_free( str );
+               str = NULL;
+       }
+
+       get( pb, SLAPI_RESULT_MATCHED, (void **)&str );
+       if ( str != NULL ) {
+               ch_free( str );
+               str = NULL;
+       }
+
        ldap_pvt_thread_mutex_destroy( &pb->pblockMutex );
 
        ch_free( pb ); 
@@ -390,9 +459,11 @@ slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value )
 
        switch ( arg ) {
         case SLAPI_CONN_DN:
-        case SLAPI_CONN_AUTHTYPE:
+        case SLAPI_CONN_AUTHMETHOD:
         case SLAPI_IBM_CONN_DN_ALT:
         case SLAPI_IBM_CONN_DN_ORIG:
+        case SLAPI_RESULT_TEXT:
+        case SLAPI_RESULT_MATCHED:
                if ( value != NULL ) {
                        pTmp = (void *)slapi_ch_strdup((char *)value);
                        if ( pTmp == NULL ) {