BI_op_extended ldap_back_exop_passwd;
static struct exop {
- struct berval *oid;
+ struct berval oid;
BI_op_extended *extended;
} exop_table[] = {
- { (struct berval *)&slap_EXOP_MODIFY_PASSWD, ldap_back_exop_passwd },
- { NULL, NULL }
+ { BER_BVC(LDAP_EXOP_MODIFY_PASSWD), ldap_back_exop_passwd },
+ { BER_BVNULL, NULL }
};
int
int i;
for ( i = 0; exop_table[i].extended != NULL; i++ ) {
- if ( bvmatch( exop_table[i].oid, &op->oq_extended.rs_reqoid ) )
+ if ( bvmatch( &exop_table[i].oid, &op->oq_extended.rs_reqoid ) )
{
-#ifdef LDAP_BACK_PROXY_AUTHZ
- struct ldapconn *lc;
+ ldapconn_t *lc;
LDAPControl **oldctrls = NULL;
int rc;
* called twice; maybe we could avoid the
* ldap_back_dobind() call inside each extended()
* call ... */
- lc = ldap_back_getconn( op, rs );
- if ( !lc || !ldap_back_dobind( lc, op, rs ) ) {
+ lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
+ if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
return -1;
}
op->o_ctrls = oldctrls;
send_ldap_result( op, rs );
rs->sr_text = NULL;
- return rs->sr_err;
+ rc = rs->sr_err;
+ goto done;
}
rc = ( *exop_table[i].extended )( op, rs );
}
op->o_ctrls = oldctrls;
+done:;
+ if ( lc != NULL ) {
+ ldap_back_release_conn( op, rs, lc );
+ }
+
return rc;
-#else /* ! LDAP_BACK_PROXY_AUTHZ */
- return ( *exop_table[i].extended )( op, rs );
-#endif /* ! LDAP_BACK_PROXY_AUTHZ */
}
}
Operation *op,
SlapReply *rs )
{
- struct ldapconn *lc;
+ ldapconn_t *lc;
req_pwdexop_s *qpw = &op->oq_pwdexop;
LDAPMessage *res;
ber_int_t msgid;
int rc, isproxy;
int do_retry = 1;
- lc = ldap_back_getconn( op, rs );
- if ( !lc || !ldap_back_dobind( lc, op, rs ) ) {
+ lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
+ if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
return -1;
}
op->o_ctrls, NULL, &msgid );
if ( rc == LDAP_SUCCESS ) {
- if ( ldap_result( lc->lc_ld, msgid, 1, NULL, &res ) == -1 ) {
+ if ( ldap_result( lc->lc_ld, msgid, LDAP_MSG_ALL, NULL, &res ) == -1 ) {
ldap_get_option( lc->lc_ld, LDAP_OPT_ERROR_NUMBER, &rc );
- ldap_back_freeconn( op, lc );
+ ldap_back_freeconn( op, lc, 0 );
lc = NULL;
} else {
(char **)&rs->sr_matched,
(char **)&rs->sr_text,
NULL, NULL, 0 );
+#ifndef LDAP_NULL_IS_NULL
+ if ( rs->sr_matched && rs->sr_matched[ 0 ] == '\0' ) {
+ free( (char *)rs->sr_matched );
+ rs->sr_matched = NULL;
+ }
+ if ( rs->sr_text && rs->sr_text[ 0 ] == '\0' ) {
+ free( (char *)rs->sr_text );
+ rs->sr_text = NULL;
+ }
+#endif /* LDAP_NULL_IS_NULL */
if ( rc == LDAP_SUCCESS ) {
if ( rs->sr_err == LDAP_SUCCESS ) {
struct berval newpw;
rs->sr_err = slap_map_api2result( rs );
if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
do_retry = 0;
- if ( ldap_back_retry(lc, op, rs ) ) {
+ if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
goto retry;
}
}
send_ldap_result( op, rs );
- if ( rs->sr_matched ) {
- free( (char *)rs->sr_matched );
- }
- if ( rs->sr_text ) {
- free( (char *)rs->sr_text );
- }
+ rc = -1;
+ }
+
+ /* these have to be freed anyway... */
+ if ( rs->sr_matched ) {
+ free( (char *)rs->sr_matched );
rs->sr_matched = NULL;
+ }
+ if ( rs->sr_text ) {
+ free( (char *)rs->sr_text );
rs->sr_text = NULL;
- rc = -1;
+ }
+
+ if ( lc != NULL ) {
+ ldap_back_release_conn( op, rs, lc );
}
return rc;