/* search.c - /etc/passwd backend search function */
/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * 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>.
+ */
+/* Portions Copyright (c) 1995 Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP). Additional significant contributors
+ * include:
+ * Hallvard B. Furuseth
+ * Howard Chu
+ * Kurt D. Zeilenga
+ */
#include "portable.h"
time_t stoptime;
LDAPRDN rdn = NULL;
- struct berval parent = { 0, NULL };
+ struct berval parent = BER_BVNULL;
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
- op->oq_search.rs_tlimit = (op->oq_search.rs_tlimit > op->o_bd->be_timelimit || op->oq_search.rs_tlimit < 1) ? op->o_bd->be_timelimit
- : op->oq_search.rs_tlimit;
- stoptime = op->o_time + op->oq_search.rs_tlimit;
- op->oq_search.rs_slimit = (op->oq_search.rs_slimit > op->o_bd->be_sizelimit || op->oq_search.rs_slimit < 1) ? op->o_bd->be_sizelimit
- : op->oq_search.rs_slimit;
+ if (op->ors_tlimit != SLAP_NO_LIMIT ) {
+ stoptime = op->o_time + op->ors_tlimit;
+ }
/* Handle a query for the base of this backend */
if ( be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
rs->sr_matched = op->o_req_dn.bv_val;
- if( op->oq_search.rs_scope != LDAP_SCOPE_ONELEVEL ) {
+ if( op->ors_scope != LDAP_SCOPE_ONELEVEL ) {
AttributeDescription *desc = NULL;
/* Create an entry corresponding to the base DN */
vals[0].bv_len = sizeof("organizationalUnit")-1;
attr_mergeit( e, ad_objectClass, vals );
- if ( test_filter( op, e, op->oq_search.rs_filter ) == LDAP_COMPARE_TRUE ) {
+ if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
- rs->sr_attrs = op->oq_search.rs_attrs;
+ rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
}
}
- if ( op->oq_search.rs_scope != LDAP_SCOPE_BASE ) {
+ if ( op->ors_scope != LDAP_SCOPE_BASE ) {
/* check all our "children" */
ldap_pvt_thread_mutex_lock( &passwd_mutex );
}
/* check time limit */
- if ( slap_get_time() > stoptime ) {
+ if ( op->ors_tlimit != SLAP_NO_LIMIT
+ && slap_get_time() > stoptime )
+ {
send_ldap_error( op, rs, LDAP_TIMELIMIT_EXCEEDED, NULL );
endpwent();
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
goto done;
}
- if ( test_filter( op, e, op->oq_search.rs_filter ) == LDAP_COMPARE_TRUE ) {
+ if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
/* check size limit */
- if ( --op->oq_search.rs_slimit == -1 ) {
+ if ( --op->ors_slimit == -1 ) {
send_ldap_error( op, rs, LDAP_SIZELIMIT_EXCEEDED, NULL );
endpwent();
ldap_pvt_thread_mutex_unlock( &passwd_mutex );
}
rs->sr_entry = e;
- rs->sr_attrs = op->oq_search.rs_attrs;
+ rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
}
goto done;
}
- if( op->oq_search.rs_scope == LDAP_SCOPE_ONELEVEL ) {
+ if( op->ors_scope == LDAP_SCOPE_ONELEVEL ) {
goto done;
}
goto done;
}
- if ( test_filter( op, e, op->oq_search.rs_filter ) == LDAP_COMPARE_TRUE ) {
+ if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE ) {
rs->sr_entry = e;
- rs->sr_attrs = op->oq_search.rs_attrs;
+ rs->sr_attrs = op->ors_attrs;
+ rs->sr_flags = REP_ENTRY_MODIFIABLE;
send_search_entry( op, rs );
}
sprintf( vals[0].bv_val, "uid=%s,%s",
pw->pw_name, be->be_suffix[0].bv_val );
- rc = dnNormalize( 0, NULL, NULL, vals, &bv );
+ rc = dnNormalize( 0, NULL, NULL, vals, &bv, NULL );
if( rc != LDAP_SUCCESS ) {
free( vals[0].bv_val );
return NULL;