📄 ldb_map_inbound.c
字号:
ac->step = MAP_MODIFY_LOCAL; handle->state = LDB_ASYNC_INIT; handle->status = LDB_SUCCESS; return ldb_next_request(ac->module, ac->local_req);}/* Modify a record. */int map_modify(struct ldb_module *module, struct ldb_request *req){ const struct ldb_message *msg = req->op.mod.message; struct ldb_handle *h; struct map_context *ac; struct ldb_message *local, *remote; /* Do not manipulate our control entries */ if (ldb_dn_is_special(msg->dn)) { return ldb_next_request(module, req); } /* No mapping requested (perhaps no DN mapping specified), skip to next module */ if (!ldb_dn_check_local(module, msg->dn)) { return ldb_next_request(module, req); } /* No mapping needed, skip to next module */ /* TODO: What if the remote part exists, the local doesn't, * and this request wants to modify local data and thus * add the local record? */ if (!ldb_msg_check_remote(module, msg)) { return LDB_ERR_OPERATIONS_ERROR; } /* Prepare context and handle */ h = map_init_handle(req, module); if (h == NULL) { return LDB_ERR_OPERATIONS_ERROR; } ac = talloc_get_type(h->private_data, struct map_context); /* Prepare the local operation */ ac->local_req = talloc(ac, struct ldb_request); if (ac->local_req == NULL) { goto oom; } *(ac->local_req) = *req; /* copy the request */ ac->local_req->context = NULL; ac->local_req->callback = NULL; /* Prepare the remote operation */ ac->remote_req = talloc(ac, struct ldb_request); if (ac->remote_req == NULL) { goto oom; } *(ac->remote_req) = *req; /* copy the request */ ac->remote_req->context = NULL; ac->remote_req->callback = NULL; /* Prepare the local message */ local = ldb_msg_new(ac->local_req); if (local == NULL) { goto oom; } local->dn = msg->dn; /* Prepare the remote message */ remote = ldb_msg_new(ac->remote_req); if (remote == NULL) { goto oom; } remote->dn = ldb_dn_map_local(ac->module, remote, msg->dn); /* Split local from remote message */ ldb_msg_partition(module, local, remote, msg); ac->local_req->op.mod.message = local; ac->remote_req->op.mod.message = remote; if ((local->num_elements == 0) || (!map_check_local_db(ac->module))) { /* No local data or db, just run the remote request */ talloc_free(ac->local_req); req->handle = h; /* return our own handle to deal with this call */ return map_modify_do_remote(h); } /* prepare the search operation */ ac->search_req = map_search_self_req(ac, msg->dn); if (ac->search_req == NULL) { goto failed; } ac->step = MAP_SEARCH_SELF_MODIFY; req->handle = h; /* return our own handle to deal with this call */ return ldb_next_request(module, ac->search_req);oom: map_oom(module);failed: talloc_free(h); return LDB_ERR_OPERATIONS_ERROR;}/* Delete the remote record. */int map_delete_do_remote(struct ldb_handle *handle){ struct map_context *ac; ac = talloc_get_type(handle->private_data, struct map_context); ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req); ac->step = MAP_DELETE_REMOTE; handle->state = LDB_ASYNC_INIT; handle->status = LDB_SUCCESS; return ldb_next_remote_request(ac->module, ac->remote_req);}/* Delete the local record. */int map_delete_do_local(struct ldb_handle *handle){ struct map_context *ac; ac = talloc_get_type(handle->private_data, struct map_context); /* No local record, continue remotely */ if (ac->local_dn == NULL) { return map_delete_do_remote(handle); } ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); ac->step = MAP_DELETE_LOCAL; handle->state = LDB_ASYNC_INIT; handle->status = LDB_SUCCESS; return ldb_next_request(ac->module, ac->local_req);}/* Delete a record. */int map_delete(struct ldb_module *module, struct ldb_request *req){ struct ldb_handle *h; struct map_context *ac; /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.del.dn)) { return ldb_next_request(module, req); } /* No mapping requested (perhaps no DN mapping specified), skip to next module */ if (!ldb_dn_check_local(module, req->op.del.dn)) { return ldb_next_request(module, req); } /* Prepare context and handle */ h = map_init_handle(req, module); if (h == NULL) { return LDB_ERR_OPERATIONS_ERROR; } ac = talloc_get_type(h->private_data, struct map_context); /* Prepare the local operation */ ac->local_req = talloc(ac, struct ldb_request); if (ac->local_req == NULL) { goto oom; } *(ac->local_req) = *req; /* copy the request */ ac->local_req->op.del.dn = req->op.del.dn; ac->local_req->context = NULL; ac->local_req->callback = NULL; /* Prepare the remote operation */ ac->remote_req = talloc(ac, struct ldb_request); if (ac->remote_req == NULL) { goto oom; } *(ac->remote_req) = *req; /* copy the request */ ac->remote_req->op.del.dn = ldb_dn_map_local(module, ac->remote_req, req->op.del.dn); /* No local db, just run the remote request */ if (!map_check_local_db(ac->module)) { req->handle = h; /* return our own handle to deal with this call */ return map_delete_do_remote(h); } ac->remote_req->context = NULL; ac->remote_req->callback = NULL; /* Prepare the search operation */ ac->search_req = map_search_self_req(ac, req->op.del.dn); if (ac->search_req == NULL) { goto failed; } req->handle = h; /* return our own handle to deal with this call */ ac->step = MAP_SEARCH_SELF_DELETE; return ldb_next_request(module, ac->search_req);oom: map_oom(module);failed: talloc_free(h); return LDB_ERR_OPERATIONS_ERROR;}/* Rename the remote record. */int map_rename_do_remote(struct ldb_handle *handle){ struct map_context *ac; ac = talloc_get_type(handle->private_data, struct map_context); ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->remote_req); ac->step = MAP_RENAME_REMOTE; handle->state = LDB_ASYNC_INIT; handle->status = LDB_SUCCESS; return ldb_next_remote_request(ac->module, ac->remote_req);}/* Update the local 'IS_MAPPED' attribute. */int map_rename_do_fixup(struct ldb_handle *handle){ struct map_context *ac; ac = talloc_get_type(handle->private_data, struct map_context); ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->down_req); ac->step = MAP_RENAME_FIXUP; handle->state = LDB_ASYNC_INIT; handle->status = LDB_SUCCESS; return ldb_next_request(ac->module, ac->down_req);}/* Rename the local record. */int map_rename_do_local(struct ldb_handle *handle){ struct map_context *ac; ac = talloc_get_type(handle->private_data, struct map_context); /* No local record, continue remotely */ if (ac->local_dn == NULL) { return map_rename_do_remote(handle); } ldb_set_timeout_from_prev_req(ac->module->ldb, ac->orig_req, ac->local_req); ac->step = MAP_RENAME_LOCAL; handle->state = LDB_ASYNC_INIT; handle->status = LDB_SUCCESS; return ldb_next_request(ac->module, ac->local_req);}/* Rename a record. */int map_rename(struct ldb_module *module, struct ldb_request *req){ struct ldb_handle *h; struct map_context *ac; /* Do not manipulate our control entries */ if (ldb_dn_is_special(req->op.rename.olddn)) { return ldb_next_request(module, req); } /* No mapping requested (perhaps no DN mapping specified), skip to next module */ if ((!ldb_dn_check_local(module, req->op.rename.olddn)) && (!ldb_dn_check_local(module, req->op.rename.newdn))) { return ldb_next_request(module, req); } /* Rename into/out of the mapped partition requested, bail out */ if (!ldb_dn_check_local(module, req->op.rename.olddn) || !ldb_dn_check_local(module, req->op.rename.newdn)) { return LDB_ERR_AFFECTS_MULTIPLE_DSAS; } /* Prepare context and handle */ h = map_init_handle(req, module); if (h == NULL) { return LDB_ERR_OPERATIONS_ERROR; } ac = talloc_get_type(h->private_data, struct map_context); /* Prepare the local operation */ ac->local_req = talloc(ac, struct ldb_request); if (ac->local_req == NULL) { goto oom; } *(ac->local_req) = *req; /* copy the request */ ac->local_req->op.rename.olddn = req->op.rename.olddn; ac->local_req->op.rename.newdn = req->op.rename.newdn; ac->local_req->context = NULL; ac->local_req->callback = NULL; /* Prepare the remote operation */ ac->remote_req = talloc(ac, struct ldb_request); if (ac->remote_req == NULL) { goto oom; } *(ac->remote_req) = *req; /* copy the request */ ac->remote_req->op.rename.olddn = ldb_dn_map_local(module, ac->remote_req, req->op.rename.olddn); ac->remote_req->op.rename.newdn = ldb_dn_map_local(module, ac->remote_req, req->op.rename.newdn); ac->remote_req->context = NULL; ac->remote_req->callback = NULL; /* No local db, just run the remote request */ if (!map_check_local_db(ac->module)) { req->handle = h; /* return our own handle to deal with this call */ return map_rename_do_remote(h); } /* Prepare the fixup operation */ /* TODO: use GUIDs here instead -- or skip it when GUIDs are used. */ ac->down_req = map_build_fixup_req(ac, req->op.rename.newdn, ac->remote_req->op.rename.newdn); if (ac->down_req == NULL) { goto failed; } /* Prepare the search operation */ ac->search_req = map_search_self_req(ac, req->op.rename.olddn); if (ac->search_req == NULL) { goto failed; } req->handle = h; /* return our own handle to deal with this call */ ac->step = MAP_SEARCH_SELF_RENAME; return ldb_next_request(module, ac->search_req);oom: map_oom(module);failed: talloc_free(h); return LDB_ERR_OPERATIONS_ERROR;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -