]> 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 33d1babe4b2e2aca2690b5fe131a650dad9ecafa..c97880c5f60f8f61c2ed59a50b1e54021998bdb0 100644 (file)
@@ -1,12 +1,23 @@
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
- */
-/*
- * Portions Copyright IBM Corp. 1997,2002-2003
+/* $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, version 2.7 or later.
+ * 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>.
+ */
+/* 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"
@@ -267,6 +278,7 @@ set( Slapi_PBlock *pb, int param, void *val )
 {
 #if defined(LDAP_SLAPI)
        int i, freeit;
+       int addcon = 0;
 
        if ( isValidParam( pb, param ) == INVALID_PARAM ) {
                return PBLOCK_ERROR;
@@ -279,6 +291,11 @@ set( Slapi_PBlock *pb, int param, void *val )
                return PBLOCK_ERROR; 
        }
 
+       if ( param == SLAPI_ADD_RESCONTROL ) {
+               addcon = 1;
+               param = SLAPI_RES_CONTROLS;
+       }
+
        switch ( param ) {
         case SLAPI_CONN_DN:
         case SLAPI_CONN_AUTHMETHOD:
@@ -300,8 +317,19 @@ set( Slapi_PBlock *pb, int param, void *val )
                pb->curParams[i] = param;
                pb->numParams++;
        }
-       if ( freeit ) ch_free( pb->curVals[i] );
-       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;