break;
case LDAP_TAG_SearchRequest:
+ /* check if we are already processing this request */
+ if (req->in_dispatch_replies) {
+ return;
+ }
+
+ req->in_dispatch_replies = true;
+
/* loop over all messages */
for (i = 0; i < req->num_replies; i++) {
if (ret != LDB_SUCCESS) {
callback_failed = true;
}
+
break;
case LDAP_TAG_SearchResultReference:
if (ret != LDB_SUCCESS) {
callback_failed = true;
}
+
break;
default:
}
}
+ req->in_dispatch_replies = false;
+
talloc_free(req->replies);
req->replies = NULL;
req->num_replies = 0;
for (i = 0; i < n; i++) {
msg->r.AddRequest.attributes[i] = mods[i]->attrib;
}
+ msg->controls = req->controls;
return ildb_request_send(ac, msg);
}
for (i = 0; i < n; i++) {
msg->r.ModifyRequest.mods[i] = *mods[i];
}
-
+ msg->controls = req->controls;
return ildb_request_send(ac, msg);
}
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
}
+ msg->controls = req->controls;
return ildb_request_send(ac, msg);
}
{
struct ldb_request *req = ac->req;
struct ldap_message *msg;
+ const char *rdn_name;
+ const struct ldb_val *rdn_val;
msg = new_ldap_message(req);
if (msg == NULL) {
return LDB_ERR_INVALID_DN_SYNTAX;
}
- msg->r.ModifyDNRequest.newrdn =
- talloc_asprintf(msg, "%s=%s",
- ldb_dn_get_rdn_name(req->op.rename.newdn),
- ldb_dn_escape_value(msg, *ldb_dn_get_rdn_val(req->op.rename.newdn)));
+ rdn_name = ldb_dn_get_rdn_name(req->op.rename.newdn);
+ rdn_val = ldb_dn_get_rdn_val(req->op.rename.newdn);
+
+ if ((rdn_name != NULL) && (rdn_val != NULL)) {
+ msg->r.ModifyDNRequest.newrdn =
+ talloc_asprintf(msg, "%s=%s", rdn_name,
+ ldb_dn_escape_value(msg, *rdn_val));
+ } else {
+ msg->r.ModifyDNRequest.newrdn = talloc_strdup(msg, "");
+ }
if (msg->r.ModifyDNRequest.newrdn == NULL) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
msg->r.ModifyDNRequest.deleteolddn = true;
+ msg->controls = req->controls;
return ildb_request_send(ac, msg);
}
struct loadparm_context *lp_ctx;
module = ldb_module_new(ldb, ldb, "ldb_ildap backend", &ildb_ops);
- if (!module) return -1;
+ if (!module) return LDB_ERR_OPERATIONS_ERROR;
ildb = talloc(module, struct ildb_private);
if (!ildb) {
status = ldap_connect(ildb->ldap, url);
if (!NT_STATUS_IS_OK(status)) {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to connect to ldap URL '%s' - %s\n",
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to connect to ldap URL '%s' - %s",
url, ldap_errstr(ildb->ldap, module, status));
goto failed;
}
const char *password = cli_credentials_get_password(creds);
status = ldap_bind_simple(ildb->ldap, bind_dn, password);
if (!NT_STATUS_IS_OK(status)) {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s\n",
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s",
ldap_errstr(ildb->ldap, module, status));
goto failed;
}
} else {
status = ldap_bind_sasl(ildb->ldap, creds, lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s\n",
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s",
ldap_errstr(ildb->ldap, module, status));
goto failed;
}
}
*_module = module;
- return 0;
+ return LDB_SUCCESS;
failed:
talloc_free(module);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
_PUBLIC_ const struct ldb_backend_ops ldb_ldap_backend_ops = {