-/*
- * Copyright (c) 2003 by International Business Machines, Inc.
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * International Business Machines, Inc. (hereinafter called IBM) grants
- * permission under its copyrights to use, copy, modify, and distribute this
- * Software with or without fee, provided that the above copyright notice and
- * all paragraphs of this notice appear in all copies, and that the name of IBM
- * not be used in connection with the marketing of any product incorporating
- * the Software or modifications thereof, without specific, written prior
- * permission.
+ * Copyright 1999-2003 The OpenLDAP Foundation.
+ * Portions Copyright 2003 IBM Corporation.
+ * All rights reserved.
*
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ * 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>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by the Howard Chu for inclusion
+ * in OpenLDAP Software and subsequently enhanced by Pierangelo
+ * Masarati and Apurva Kumar.
+ */
+/* This is an altered version */
+/*
* This software is based on the backends back-ldap and back-meta, implemented
* by Howard Chu <hyc@highlandsun.com>, Mark Valence
* <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other
#include "ldap_log.h"
#include "../../../libraries/libldap/ldap-int.h"
-#ifdef LDAP_CACHING
static Entry*
meta_create_entry(
Backend *be,
int num_entries = 0;
int curr_limit;
int fattr_cnt=0;
+ int oc_attr_absent = 1;
-
struct exception result[1];
Filter* filter = str2filter(op->ors_filterstr.bv_val);
cb.sc_private = op->o_bd;
if (op->ors_attrs) {
- for ( count=0; op->ors_attrs[ count ].an_name.bv_val; count++ )
- ;
- attrs = (AttributeName*)malloc( ( count + 1 ) *
- sizeof(AttributeName));
+ for ( count=0; op->ors_attrs[ count ].an_name.bv_val; count++ ) {
+ if ( op->ors_attrs[count].an_desc == slap_schema.si_ad_objectClass )
+ oc_attr_absent = 0;
+ }
+ attrs = (AttributeName*)malloc( ( count + 1 + oc_attr_absent )
+ *sizeof(AttributeName));
for ( count=0; op->ors_attrs[ count ].an_name.bv_val; count++ ) {
ber_dupbv(&attrs[ count ].an_name,
&op->ors_attrs[ count ].an_name);
attrs[ count ].an_name.bv_len = 0;
}
-
result->type = SUCCESS;
result->rc = 0;
ldap_pvt_thread_mutex_lock(&cm->cache_mutex);
}
}
+ if ( attrs && oc_attr_absent ) {
+ for ( count = 0; attrs[count].an_name.bv_val; count++) ;
+ attrs[ count ].an_name.bv_val = "objectClass";
+ attrs[ count ].an_name.bv_len = strlen( "objectClass" );
+ attrs[ count ].an_desc = slap_schema.si_ad_objectClass;
+ attrs[ count + 1 ].an_name.bv_val = NULL;
+ attrs[ count + 1 ].an_name.bv_len = 0;
+ }
+
if (answerable) {
Operation op_tmp;
op_tmp.o_req_dn = cachebase;
op_tmp.o_req_ndn = ncachebase;
- op_tmp.o_caching_on = 1;
op_tmp.o_callback = &cb;
li->glue_be->be_search(&op_tmp, rs);
*/
msgid[ i ] = ldap_search( lsc->ld, mbase, realscope,
mapped_filter, mapped_attrs,
- op->ors_attrsonly );
+ op->ors_attrsonly );
if ( msgid[ i ] == -1 ) {
result->type = CONN_ERR;
Debug( LDAP_DEBUG_ANY, "QUERY CACHEABLE\n", 0, 0, 0 );
#endif /* !NEW_LOGGING */
op_tmp.o_bd = li->glue_be;
- uuid = cache_entries(&op_tmp, rs, entry_array,
- cm, result);
+ uuid = cache_entries(&op_tmp, rs, entry_array, cm, result);
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, DETAIL1,
"Added query %s UUID %s ENTRIES %d\n",
goto Catch;
filter = 0;
attrs = 0;
+
+ /* FIXME : launch do_syncrepl() threads around here
+ *
+ * entryUUID and entryCSN need also to be requested by :
+ */
+ /*
+ msgid[ i ] = ldap_search( lsc->ld, mbase, realscope,
+ mapped_filter, mapped_attrs, op->ors_attrsonly );
+ */
+ /* Also, mbase, realscope, mapped_filter, mapped_attrs need
+ * be managed as arrays. Each element needs to be retained by this point.
+ */
+
} else {
#ifdef NEW_LOGGING
LDAP_LOG( BACK_META, DETAIL1,
struct berval a, mapped;
Entry* ent;
BerElement ber = *e->lm_ber;
- Attribute *attr, **attrp;
- struct berval dummy = { 0, NULL };
- struct berval *bv, bdn;
- const char *text;
- char* ename = NULL;
+ Attribute *attr, *soc_attr, **attrp;
+ struct berval dummy = { 0, NULL };
+ struct berval *bv, bdn;
+ const char *text = NULL;
+ char* ename = NULL;
+ struct berval sc = { 0, NULL };
+ char textbuf[SLAP_TEXT_BUFLEN];
+ size_t textlen = sizeof(textbuf);
+
if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) {
result->type = CREATE_ENTRY_ERR;
return NULL;
if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR
|| attr->a_vals == NULL ) {
attr->a_vals = &dummy;
+#if 0
} else if ( attr->a_desc == slap_schema.si_ad_objectClass ||
attr->a_desc ==
slap_schema.si_ad_structuralObjectClass) {
+#else
+ } else if ( attr->a_desc == slap_schema.si_ad_objectClass ) {
+#endif
int i, last;
for ( last = 0; attr->a_vals[ last ].bv_val; ++last )
;
ber_dupbv( bv, &mapped );
}
}
+
+ structural_class( attr->a_vals, &sc, NULL, &text, textbuf, textlen );
+ soc_attr = (Attribute*) ch_malloc( sizeof( Attribute ));
+ soc_attr->a_desc = slap_schema.si_ad_structuralObjectClass;
+ soc_attr->a_vals = (BerVarray) ch_malloc( 2* sizeof( BerValue ));
+ ber_dupbv( &soc_attr->a_vals[0], &sc );
+ soc_attr->a_vals[1].bv_len = 0;
+ soc_attr->a_vals[1].bv_val = NULL;
+ soc_attr->a_nvals = (BerVarray) ch_malloc( 2* sizeof( BerValue ));
+ ber_dupbv( &soc_attr->a_nvals[0], &sc );
+ soc_attr->a_nvals[1].bv_len = 0;
+ soc_attr->a_nvals[1].bv_val = NULL;
+
+ *attrp = soc_attr;
+ attrp = &soc_attr->a_next;
+
/*
* It is necessary to try to rewrite attributes with
* dn syntax because they might be used in ACLs as
*attrp = attr;
attrp = &attr->a_next;
}
+
return ent;
}
if (attrs == NULL) {
(*new_attrs)[0].an_name.bv_val = "*";
(*new_attrs)[0].an_name.bv_len = 1;
+ (*new_attrs)[1].an_name.bv_val = NULL;
+ (*new_attrs)[1].an_name.bv_len = 0;
alluser = 1;
allop = 0;
} else {
(*new_attrs)[i].an_name = attrs[i].an_name;
(*new_attrs)[i].an_desc = attrs[i].an_desc;
}
+ (*new_attrs)[count].an_name.bv_val = NULL;
+ (*new_attrs)[count].an_name.bv_len = 0;
alluser = an_find(*new_attrs, &all_user);
allop = an_find(*new_attrs, &all_op);
}
- (*new_attrs)[count].an_name.bv_val = NULL;
- (*new_attrs)[count].an_name.bv_len = 0;
for ( i=0; filter_attrs[i].an_name.bv_val; i++ ) {
if ( an_find(*new_attrs, &filter_attrs[i].an_name ))
rs->sr_entry->e_nname = ndn;
op->o_callback = cb;
- return 0;
+ return LDAP_SUCCESS;
+
} else if (rs->sr_type == REP_RESULT) {
op->o_callback = NULL;
send_ldap_result( op, rs );
- return 0;
+ return LDAP_SUCCESS;
}
+
+ return LDAP_SUCCESS;
}
-#endif