diff options
author | Andrew Bartlett <abartlet@samba.org> | 2008-12-16 08:59:05 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2008-12-17 12:29:27 +1100 |
commit | 596fe759e1fed835173146a74ac9986066acc48e (patch) | |
tree | dfd67129f0d768c57179d9fcd5a59d8ba656f8d4 /source4/lib/ldb/common | |
parent | 18ef32f4ce6e1fe240aa042a81fb493eaae421af (diff) | |
download | samba-596fe759e1fed835173146a74ac9986066acc48e.tar.gz samba-596fe759e1fed835173146a74ac9986066acc48e.tar.bz2 samba-596fe759e1fed835173146a74ac9986066acc48e.zip |
s4:ldb: make it possible to return per entry controls
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb_controls.c | 20 | ||||
-rw-r--r-- | source4/lib/ldb/common/ldb_modules.c | 6 |
2 files changed, 25 insertions, 1 deletions
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c index e3f8551407..6fad5012b6 100644 --- a/source4/lib/ldb/common/ldb_controls.c +++ b/source4/lib/ldb/common/ldb_controls.c @@ -53,6 +53,26 @@ struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char return NULL; } +/* check if a control with the specified "oid" exist and return it */ +/* returns NULL if not found */ +struct ldb_control *ldb_reply_get_control(struct ldb_reply *rep, const char *oid) +{ + int i; + + /* check if there's a paged request control */ + if (rep->controls != NULL) { + for (i = 0; rep->controls[i]; i++) { + if (strcmp(oid, rep->controls[i]->oid) == 0) { + break; + } + } + + return rep->controls[i]; + } + + return NULL; +} + /* saves the current controls list into the "saver" and replace the one in req with a new one excluding the "exclude" control */ /* returns False on error */ diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c index ab0f4c51cc..8db28d262c 100644 --- a/source4/lib/ldb/common/ldb_modules.c +++ b/source4/lib/ldb/common/ldb_modules.c @@ -587,10 +587,13 @@ struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb) * req: the original request passed to your module * msg: reply message (must be a talloc pointer, and it will be stolen * on the ldb_reply that is sent to the callback) + * ctrls: controls to send in the reply (must be a talloc pointer, and it will be stolen + * on the ldb_reply that is sent to the callback) */ int ldb_module_send_entry(struct ldb_request *req, - struct ldb_message *msg) + struct ldb_message *msg, + struct ldb_control **ctrls) { struct ldb_reply *ares; @@ -602,6 +605,7 @@ int ldb_module_send_entry(struct ldb_request *req, } ares->type = LDB_REPLY_ENTRY; ares->message = talloc_steal(ares, msg); + ares->controls = talloc_steal(ares, ctrls); ares->error = LDB_SUCCESS; return req->callback(req, ares); |