From c0571f623406ca33a4d5ce616c743479335eeba0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 12 Jan 2005 02:40:25 +0000 Subject: r4698: - Initial implementation of trusted domains in LSA. - Use templates for Secrets and the new trusted domains - Auto-add modifiedTime, createdTime and objectGUID to records in the samdb layer. Andrew Bartlett (This used to be commit 271c8faadfe2d9e0f3d523a1cdc831f5f9e35d19) --- source4/dsdb/samdb/samdb.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'source4/dsdb/samdb') diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c index 0f72f2a1d6..81ce05d9fe 100644 --- a/source4/dsdb/samdb/samdb.c +++ b/source4/dsdb/samdb/samdb.c @@ -23,12 +23,13 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_netlogon.h" #include "lib/ldb/include/ldb.h" +#include "system/time.h" /* connect to the SAM database return an opaque context pointer on success, or NULL on failure */ -void *samdb_connect(TALLOC_CTX *mem_ctx) +struct ldb_wrap *samdb_connect(TALLOC_CTX *mem_ctx) { return ldb_wrap_connect(mem_ctx, lp_sam_url(), 0, NULL); } @@ -604,7 +605,9 @@ int samdb_copy_template(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, strcasecmp((char *)el->values[j].data, "userTemplate") == 0 || strcasecmp((char *)el->values[j].data, "groupTemplate") == 0 || strcasecmp((char *)el->values[j].data, "foreignSecurityTemplate") == 0 || - strcasecmp((char *)el->values[j].data, "aliasTemplate") == 0)) { + strcasecmp((char *)el->values[j].data, "aliasTemplate") == 0 || + strcasecmp((char *)el->values[j].data, "trustedDomainTemplate") == 0 || + strcasecmp((char *)el->values[j].data, "secretTemplate") == 0)) { continue; } samdb_msg_add_string(sam_ctx, mem_ctx, msg, el->name, @@ -919,6 +922,19 @@ int samdb_msg_set_ldaptime(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct */ int samdb_add(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg) { + struct GUID guid; + const char *guidstr; + time_t now = time(NULL); + /* a new GUID */ + guid = GUID_random(); + guidstr = GUID_string(mem_ctx, &guid); + if (!guidstr) { + return -1; + } + + samdb_msg_add_string(sam_ctx, mem_ctx, msg, "objectGUID", guidstr); + samdb_msg_set_ldaptime(sam_ctx, mem_ctx, msg, "whenCreated", now); + samdb_msg_set_ldaptime(sam_ctx, mem_ctx, msg, "whenChanged", now); return ldb_add(sam_ctx->ldb, msg); } @@ -935,6 +951,8 @@ int samdb_delete(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, const char *dn) */ int samdb_modify(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg) { + time_t now = time(NULL); + samdb_msg_set_ldaptime(sam_ctx, mem_ctx, msg, "whenChanged", now); return ldb_modify(sam_ctx->ldb, msg); } -- cgit