r20852: add a function to add a ldb control to a ldb_request
authorStefan Metzmacher <metze@samba.org>
Wed, 17 Jan 2007 16:10:33 +0000 (16:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:43:40 +0000 (14:43 -0500)
metze
(This used to be commit f0bf86ed66f7f9995df35db55f2f3875e7dbacbe)

source4/lib/ldb/common/ldb_controls.c
source4/lib/ldb/include/ldb.h

index d2729c82ab85e080507fbaa87ae5cccad8422c71..182e1b41d48166aefb534031b6906f9c64783f4e 100644 (file)
@@ -104,3 +104,31 @@ int check_critical_controls(struct ldb_control **controls)
 
        return 0;
 }
+
+int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data)
+{
+       unsigned n;
+       struct ldb_control **ctrls;
+       struct ldb_control *ctrl;
+
+       for (n=0; req->controls && req->controls[n];) { n++; }
+
+       ctrls = talloc_realloc(req, req->controls,
+                              struct ldb_control *,
+                              n + 2);
+       if (!ctrls) return LDB_ERR_OPERATIONS_ERROR;
+       req->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;
+}
index 62afbfb609d88566eb5c9ad9a1e4613a91791438..9cc590434869ea5415d6d27d6cb25fae5c2a035b 100644 (file)
@@ -989,6 +989,18 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
                        void *context,
                        ldb_request_callback_t callback);
 
+/**
+  Add a ldb_control to a ldb_request
+
+  \param req the request struct where to add the control
+  \param oid the object identifier of the control as string
+  \param ciritical whether the control should be critical or not
+  \param data a talloc pointer to the control specific data
+
+  \return result code (LDB_SUCCESS on success, or a failure code)
+*/
+int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data);
+
 /**
   Search the database