summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-05-13 21:08:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:06:00 -0500
commitaa7a02d45fefad3640f273b1d3bfe535a1e6b88c (patch)
tree548f2e54edc24c21984c11deed35813b015a3809 /source4
parent3064782735e927de63cdfa34a19c95a9d099a82a (diff)
downloadsamba-aa7a02d45fefad3640f273b1d3bfe535a1e6b88c.tar.gz
samba-aa7a02d45fefad3640f273b1d3bfe535a1e6b88c.tar.bz2
samba-aa7a02d45fefad3640f273b1d3bfe535a1e6b88c.zip
r15582: Commit some forgotten stuff that have been setting on my private tree fro long
(This used to be commit 7c050b541e98cd442a0c9ed0ddadb3e573cd1304)
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectguid.c75
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c10
-rw-r--r--source4/lib/ldb/common/ldb_msg.c17
-rw-r--r--source4/lib/ldb/include/ldb.h8
4 files changed, 96 insertions, 14 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c
index 7169aa6842..699f04775c 100644
--- a/source4/dsdb/samdb/ldb_modules/objectguid.c
+++ b/source4/dsdb/samdb/ldb_modules/objectguid.c
@@ -1,7 +1,7 @@
/*
ldb database library
- Copyright (C) Simo Sorce 2004
+ Copyright (C) Simo Sorce 2004-2006
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
** NOTE! The following LGPL license applies to the ldb
@@ -34,8 +34,7 @@
*/
#include "includes.h"
-#include "ldb/include/ldb.h"
-#include "ldb/include/ldb_private.h"
+#include "ldb/include/includes.h"
#include "librpc/gen_ndr/ndr_misc.h"
static struct ldb_message_element *objectguid_find_attribute(const struct ldb_message *msg, const char *name)
@@ -108,6 +107,73 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
return ret;
}
+static int objectguid_add_async(struct ldb_module *module, struct ldb_request *req)
+{
+ struct ldb_request *down_req;
+ struct ldb_message_element *attribute;
+ struct ldb_message *msg;
+ struct ldb_val v;
+ struct GUID guid;
+ NTSTATUS nt_status;
+ int ret;
+
+ ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
+
+ /* do not manipulate our control entries */
+ if (ldb_dn_is_special(req->op.add.message->dn)) {
+ return ldb_next_request(module, req);
+ }
+
+ if ((attribute = objectguid_find_attribute(req->op.add.message, "objectGUID")) != NULL ) {
+ return ldb_next_request(module, req);
+ }
+
+ down_req = talloc(req, struct ldb_request);
+ if (down_req == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ /* we have to copy the message as the caller might have it as a const */
+ msg = ldb_msg_copy_shallow(down_req, req->op.add.message);
+ if (msg == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ /* a new GUID */
+ guid = GUID_random();
+
+ nt_status = ndr_push_struct_blob(&v, msg, &guid,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ return -1;
+ }
+
+ ret = ldb_msg_add_value(msg, "objectGUID", &v);
+ if (ret) {
+ return ret;
+ }
+
+ down_req->op.add.message = msg;
+
+ down_req->controls = req->controls;
+ down_req->creds = req->creds;
+
+ down_req->async.context = req->async.context;
+ down_req->async.callback = req->async.callback;
+ down_req->async.timeout = req->async.timeout;
+
+ /* go on with the call chain */
+ ret = ldb_next_request(module, down_req);
+
+ /* do not free down_req as the call results may be linked to it,
+ * it will be freed when the upper level request get freed */
+ if (ret == LDB_SUCCESS) {
+ req->async.handle = down_req->async.handle;
+ }
+
+ return ret;
+}
+
static int objectguid_request(struct ldb_module *module, struct ldb_request *req)
{
switch (req->operation) {
@@ -115,6 +181,9 @@ static int objectguid_request(struct ldb_module *module, struct ldb_request *req
case LDB_REQ_ADD:
return objectguid_add(module, req);
+ case LDB_ASYNC_ADD:
+ return objectguid_add_async(module, req);
+
default:
return ldb_next_request(module, req);
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index cfc7192543..f8a151ddda 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -859,20 +859,12 @@ static int samldb_add_async(struct ldb_module *module, struct ldb_request *req)
}
}
+ *down_req = *req;
if (msg2 != NULL) {
down_req->op.add.message = talloc_steal(down_req, msg2);
- } else {
- down_req->op.add.message = msg;
}
- down_req->controls = req->controls;
- down_req->creds = req->creds;
-
- down_req->async.context = req->async.context;
- down_req->async.callback = req->async.callback;
- down_req->async.timeout = req->async.timeout;
-
/* go on with the call chain */
ret = ldb_next_request(module, down_req);
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index f76d7e8dd9..b09f2ce6ed 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -724,3 +724,20 @@ void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *
}
}
+int ldb_msg_check_string_attribute(const struct ldb_message *msg, const char *name, const char *value)
+{
+ struct ldb_message_element *el;
+ struct ldb_val val;
+
+ el = ldb_msg_find_element(msg, name);
+ if (el == NULL)
+ return 0;
+
+ val.data = discard_const(value);
+ val.length = strlen(value) + 1;
+
+ if (ldb_msg_find_val(el, &val))
+ return 1;
+
+ return 0;
+}
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index af3aed24c6..866b062d06 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -625,11 +625,11 @@ struct ldb_search {
};
struct ldb_add {
- const struct ldb_message *message;
+ struct ldb_message *message;
};
struct ldb_modify {
- const struct ldb_message *message;
+ struct ldb_message *message;
};
struct ldb_delete {
@@ -1178,6 +1178,10 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
struct ldb_message *msg1,
struct ldb_message *msg2);
+int ldb_msg_check_string_attribute(const struct ldb_message *msg,
+ const char *name,
+ const char *value);
+
/**
Integrity check an ldb_message