svn commit: samba r17373 - in branches/SOC/mkhl/samdb-map/ldb_modules: .

abartlet at samba.org abartlet at samba.org
Wed Aug 2 02:33:33 GMT 2006


Author: abartlet
Date: 2006-08-02 02:33:32 +0000 (Wed, 02 Aug 2006)
New Revision: 17373

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17373

Log:
Add new module entryUUID, using ldb_map infrustruture.

Andrew Bartlett

Added:
   branches/SOC/mkhl/samdb-map/ldb_modules/entryUUID.c
Modified:
   branches/SOC/mkhl/samdb-map/ldb_modules/config.mk


Changeset:
Modified: branches/SOC/mkhl/samdb-map/ldb_modules/config.mk
===================================================================
--- branches/SOC/mkhl/samdb-map/ldb_modules/config.mk	2006-08-02 02:24:00 UTC (rev 17372)
+++ branches/SOC/mkhl/samdb-map/ldb_modules/config.mk	2006-08-02 02:33:32 UTC (rev 17373)
@@ -33,6 +33,18 @@
 # End MODULE ldb_samldb
 ################################################
 
+################################################
+# Start MODULE ldb_entryUUID
+[MODULE::ldb_entryUUID]
+SUBSYSTEM = ldb
+INIT_FUNCTION = ldb_entryUUID_module_init
+ENABLE = YES
+OBJ_FILES = \
+		entryUUID.o
+#
+# End MODULE ldb_entryUUID
+################################################
+
 # ################################################
 # # Start MODULE ldb_proxy
 # [MODULE::ldb_proxy]

Added: branches/SOC/mkhl/samdb-map/ldb_modules/entryUUID.c
===================================================================
--- branches/SOC/mkhl/samdb-map/ldb_modules/entryUUID.c	2006-08-02 02:24:00 UTC (rev 17372)
+++ branches/SOC/mkhl/samdb-map/ldb_modules/entryUUID.c	2006-08-02 02:33:32 UTC (rev 17373)
@@ -0,0 +1,107 @@
+/* 
+   ldb database library - Samba3 SAM compatibility backend
+
+   Copyright (C) Jelmer Vernooij 2005
+*/
+
+#include "includes.h"
+#include "ldb/include/ldb.h"
+#include "ldb/include/ldb_private.h"
+#include "ldb/include/ldb_errors.h"
+#include "ldb/modules/ldb_map.h"
+
+#include "librpc/gen_ndr/ndr_misc.h"
+#include "librpc/ndr/libndr.h"
+
+static struct ldb_val encode_guid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
+{
+	struct GUID guid;
+	NTSTATUS status = GUID_from_string((char *)val->data, &guid);
+	struct ldb_val out = data_blob(NULL, 0);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		return out;
+	}
+	status = ndr_push_struct_blob(&out, ctx, &guid, 
+				      (ndr_push_flags_fn_t)ndr_push_GUID);
+	if (!NT_STATUS_IS_OK(status)) {
+		return out;
+	}
+
+	return out;
+}
+
+static struct ldb_val decode_guid(struct ldb_module *module, TALLOC_CTX *ctx, const struct ldb_val *val)
+{
+	struct GUID *guid;
+	NTSTATUS status;
+	struct ldb_val out = data_blob(NULL, 0);
+	
+	guid = talloc(ctx, struct GUID);
+	if (guid == NULL) {
+		return out;
+	}
+	status = ndr_pull_struct_blob(val, guid, guid, 
+				      (ndr_pull_flags_fn_t)ndr_pull_GUID);
+	if (!NT_STATUS_IS_OK(status)) {
+		talloc_free(guid);
+		return out;
+	}
+	out = data_blob_string_const(GUID_string(ctx, guid));
+	talloc_free(guid);
+	return out;
+}
+
+const struct ldb_map_attribute entryUUID_attributes[] = 
+{
+	/* objectGUID */
+	{
+		.local_name = "objectGUID",
+		.type = MAP_CONVERT,
+		.u = {
+			.convert = {
+				.remote_name = "entryUUID", 
+				.convert_local = decode_guid,
+				.convert_remote = encode_guid,
+			},
+		},
+	},
+	{
+		.local_name = "*",
+		.type = MAP_KEEP,
+	},
+	{
+		.local_name = NULL,
+	}
+};
+
+/* the context init function */
+static int entryUUID_init(struct ldb_module *module)
+{
+        int ret;
+
+	ret = ldb_map_init(module, entryUUID_attributes, NULL, NULL);
+        if (ret != LDB_SUCCESS)
+                return ret;
+
+        return ldb_next_init(module);
+}
+
+static struct ldb_module_ops entryUUID_ops = {
+	.name		   = "entryUUID",
+	.init_context	   = entryUUID_init,
+};
+
+/* the init function */
+int ldb_entryUUID_module_init(void)
+{
+	struct ldb_module_ops ops = ldb_map_get_ops();
+	entryUUID_ops.add	= ops.add;
+	entryUUID_ops.modify	= ops.modify;
+	entryUUID_ops.del	= ops.del;
+	entryUUID_ops.rename	= ops.rename;
+	entryUUID_ops.search	= ops.search;
+	entryUUID_ops.wait	= ops.wait;
+
+	return ldb_register_module(&entryUUID_ops);
+}



More information about the samba-cvs mailing list