diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-10-15 10:45:44 +1100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-10-21 22:43:53 +1100 |
commit | 17237f18f09798c90b2234150d502ccd21eb5880 (patch) | |
tree | 0f4f8bfac49a45b8bfd1df8bec62e71c586a0501 /source4/lib/ldb/common | |
parent | be5f0818ea89f08c5045e44604c9ba7d63ad1e29 (diff) | |
download | samba-17237f18f09798c90b2234150d502ccd21eb5880.tar.gz samba-17237f18f09798c90b2234150d502ccd21eb5880.tar.bz2 samba-17237f18f09798c90b2234150d502ccd21eb5880.zip |
s4:ldb Add function to add controls to an LDB reply
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb_controls.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c index a8dd6b5859..0ecb1eb62c 100644 --- a/source4/lib/ldb/common/ldb_controls.c +++ b/source4/lib/ldb/common/ldb_controls.c @@ -160,6 +160,40 @@ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool criti return LDB_SUCCESS; } +int ldb_reply_add_control(struct ldb_reply *ares, const char *oid, bool critical, void *data) +{ + unsigned n; + struct ldb_control **ctrls; + struct ldb_control *ctrl; + + for (n=0; ares->controls && ares->controls[n];) { + /* having two controls of the same OID makes no sense */ + if (strcmp(oid, ares->controls[n]->oid) == 0) { + return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; + } + n++; + } + + ctrls = talloc_realloc(ares, ares->controls, + struct ldb_control *, + n + 2); + if (!ctrls) return LDB_ERR_OPERATIONS_ERROR; + ares->controls = ctrls; + ctrls[n] = NULL; + ctrls[n+1] = NULL; + + ctrl = talloc(ctrls, struct ldb_control); + if (!ctrl) return LDB_ERR_OPERATIONS_ERROR; + + ctrl->oid = talloc_strdup(ctrl, oid); + if (!ctrl->oid) return LDB_ERR_OPERATIONS_ERROR; + ctrl->critical = critical; + ctrl->data = data; + + ctrls[n] = ctrl; + return LDB_SUCCESS; +} + /* Parse controls from the format used on the command line and in ejs */ struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *mem_ctx, const char **control_strings) |