-/*
- * Copyright 1998-2003 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 1999-2003 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>.
+ */
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by the Howard Chu for inclusion
+ * in OpenLDAP Software and subsequently enhanced by Pierangelo
+ * Masarati.
+ */
+/* This is an altered version */
+/*
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
*
* This work has been developed to fulfill the requirements
struct metaconn *lc1 = ( struct metaconn * )c1;
struct metaconn *lc2 = ( struct metaconn * )c2;
- return ( ( lc1->conn < lc2->conn ) ? -1 :
- ( ( lc1->conn > lc2-> conn ) ? 1 : 0 ) );
+ return SLAP_PTRCMP( lc1->conn, lc2->conn );
}
/*
}
lc->conns[ ntargets ].candidate = META_LAST_CONN;
+ for ( ; ntargets-- > 0; ) {
+ lc->conns[ ntargets ].ld = NULL;
+ lc->conns[ ntargets ].bound_dn.bv_val = NULL;
+ lc->conns[ ntargets ].bound_dn.bv_len = 0;
+ lc->conns[ ntargets ].cred.bv_val = NULL;
+ lc->conns[ ntargets ].cred.bv_len = 0;
+ lc->conns[ ntargets ].bound = META_UNBOUND;
+ }
+
lc->bound_target = META_BOUND_NONE;
return lc;
struct metasingleconn *lsc
)
{
+ struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
int vers;
+ dncookie dc;
/*
* Already init'ed
/* FIXME: configurable? */
ldap_set_option(lsc->ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON);
+ /*
+ * Set the network timeout if set
+ */
+ if (li->network_timeout != 0){
+ struct timeval network_timeout;
+
+ network_timeout.tv_usec = 0;
+ network_timeout.tv_sec = li->network_timeout;
+
+ ldap_set_option( lsc->ld, LDAP_OPT_NETWORK_TIMEOUT, (void *) &network_timeout);
+ }
+
/*
* Sets a cookie for the rewrite session
*/
- ( void )rewrite_session_init( lt->rwinfo, op->o_conn );
+ ( void )rewrite_session_init( lt->rwmap.rwm_rw, op->o_conn );
/*
* If the connection dn is not null, an attempt to rewrite it is made
*/
if ( op->o_conn->c_dn.bv_len != 0 ) {
+ dc.rwmap = <->rwmap;
+ dc.conn = op->o_conn;
+ dc.rs = rs;
+ dc.ctx = "bindDn";
/*
* Rewrite the bind dn if needed
*/
- lsc->bound_dn.bv_val = NULL;
- switch ( rewrite_session( lt->rwinfo, "bindDn",
- op->o_conn->c_dn.bv_val, op->o_conn,
- &lsc->bound_dn.bv_val ) ) {
- case REWRITE_REGEXEC_OK:
- if ( lsc->bound_dn.bv_val == NULL ) {
- ber_dupbv( &lsc->bound_dn, &op->o_conn->c_dn );
- }
-#ifdef NEW_LOGGING
- LDAP_LOG( BACK_META, DETAIL1,
- "[rw] bindDn: \"%s\" -> \"%s\"\n",
- op->o_conn->c_dn.bv_val,
- lsc->bound_dn.bv_val, 0 );
-#else /* !NEW_LOGGING */
- Debug( LDAP_DEBUG_ARGS,
- "rw> bindDn: \"%s\" -> \"%s\"\n",
- op->o_conn->c_dn.bv_val,
- lsc->bound_dn.bv_val, 0 );
-#endif /* !NEW_LOGGING */
- break;
-
- case REWRITE_REGEXEC_UNWILLING:
- rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
- rs->sr_text = "Operation not allowed";
-#if 0
- send_ldap_result( conn, op,
- LDAP_UNWILLING_TO_PERFORM,
- NULL, "Operation not allowed",
- NULL, NULL );
-#endif
- return rs->sr_err;
-
- case REWRITE_REGEXEC_ERR:
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "Rewrite error";
-#if 0
- send_ldap_result( conn, op,
- LDAP_OTHER,
- NULL, "Rewrite error",
- NULL, NULL );
-#endif
+ if ( ldap_back_dn_massage( &dc, &op->o_conn->c_dn,
+ &lsc->bound_dn) ) {
+ send_ldap_result( op, rs );
return rs->sr_err;
}