svn commit: samba r15582 - in branches/SAMBA_4_0/source:
dsdb/samdb/ldb_modules lib/ldb/common lib/ldb/include
idra at samba.org
idra at samba.org
Sat May 13 21:08:37 GMT 2006
Author: idra
Date: 2006-05-13 21:08:37 +0000 (Sat, 13 May 2006)
New Revision: 15582
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15582
Log:
Commit some forgotten stuff that have been setting on my private tree fro long
Modified:
branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/objectguid.c
branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c
branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c
branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/objectguid.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/objectguid.c 2006-05-13 21:03:47 UTC (rev 15581)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/objectguid.c 2006-05-13 21:08:37 UTC (rev 15582)
@@ -1,7 +1,7 @@
/*
ldb database library
- Copyright (C) Simo Sorce 2004
+ Copyright (C) Simo Sorce 2004-2006
Copyright (C) Andrew Bartlett <abartlet at 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 @@
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 @@
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);
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c 2006-05-13 21:03:47 UTC (rev 15581)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/samldb.c 2006-05-13 21:08:37 UTC (rev 15582)
@@ -859,20 +859,12 @@
}
}
+ *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);
Modified: branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c 2006-05-13 21:03:47 UTC (rev 15581)
+++ branches/SAMBA_4_0/source/lib/ldb/common/ldb_msg.c 2006-05-13 21:08:37 UTC (rev 15582)
@@ -724,3 +724,20 @@
}
}
+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;
+}
Modified: branches/SAMBA_4_0/source/lib/ldb/include/ldb.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2006-05-13 21:03:47 UTC (rev 15581)
+++ branches/SAMBA_4_0/source/lib/ldb/include/ldb.h 2006-05-13 21:08:37 UTC (rev 15582)
@@ -625,11 +625,11 @@
};
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 *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
More information about the samba-cvs
mailing list