char *errmsgp = NULL;
char **referralsp = NULL;
LDAPControl **serverctrlsp = NULL;
+ int ret;
type = ldap_msgtype(result);
lldb_add_msg_attr(ac->module->ldb, ares->message, attr, bval);
ldap_value_free_len(bval);
}
-
- ldap_memfree(attr);
}
if (berptr) ber_free(berptr, 0);
ares->type = LDB_REPLY_ENTRY;
handle->state = LDB_ASYNC_PENDING;
- handle->status = ac->callback(ac->module->ldb, ac->context, ares);
-
- ldap_msgfree(result);
+ ret = ac->callback(ac->module->ldb, ac->context, ares);
+ if (ret != LDB_SUCCESS) {
+ handle->status = ret;
+ }
+ } else {
+ handle->status = LDB_ERR_PROTOCOL_ERROR;
+ handle->state = LDB_ASYNC_DONE;
}
break;
ares->referral = talloc_strdup(ares, *referralsp);
ares->type = LDB_REPLY_REFERRAL;
handle->state = LDB_ASYNC_PENDING;
- handle->status = ac->callback(ac->module->ldb, ac->context, ares);
+ ret = ac->callback(ac->module->ldb, ac->context, ares);
+ if (ret != LDB_SUCCESS) {
+ handle->status = ret;
+ }
break;
ares->type = LDB_REPLY_DONE;
handle->state = LDB_ASYNC_DONE;
- handle->status = ac->callback(ac->module->ldb, ac->context, ares);
+ ret = ac->callback(ac->module->ldb, ac->context, ares);
+ if (ret != LDB_SUCCESS) {
+ handle->status = ret;
+ }
break;
break;
default:
- handle->state = LDB_ERR_PROTOCOL_ERROR;
+ handle->status = LDB_ERR_PROTOCOL_ERROR;
+ goto error;
}
if (matcheddnp) ldap_memfree(matcheddnp);
if (referralsp) ldap_value_free(referralsp);
if (serverctrlsp) ldap_controls_free(serverctrlsp);
+ ldap_msgfree(result);
return handle->status;
error:
handle->state = LDB_ASYNC_DONE;
+ ldap_msgfree(result);
return handle->status;
}