summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-07-08 05:14:46 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:21 -0500
commit5a176571d8aad1c0923e18f8c77ed00261b8d53a (patch)
tree9d8e9e9b95d0e5b52784eaf0ca071ea6aeb0e78e /source4/dsdb
parent06a4e5688e05f1989a661815bd75e23d1f54e443 (diff)
downloadsamba-5a176571d8aad1c0923e18f8c77ed00261b8d53a.tar.gz
samba-5a176571d8aad1c0923e18f8c77ed00261b8d53a.tar.bz2
samba-5a176571d8aad1c0923e18f8c77ed00261b8d53a.zip
r8224: - add objectGUID ldif_handler
- fix some compiler warnings metze (This used to be commit e6c39241bf93336d4c94c43f9d8beb69018fb74a)
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/samdb.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index e2426738da..f51d3c6102 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -350,17 +350,22 @@ struct dom_sid *samdb_result_dom_sid(TALLOC_CTX *mem_ctx, struct ldb_message *ms
*/
struct GUID samdb_result_guid(struct ldb_message *msg, const char *attr)
{
+ const struct ldb_val *v;
NTSTATUS status;
struct GUID guid;
- const char *guidstr = ldb_msg_find_string(msg, attr, NULL);
+ TALLOC_CTX *mem_ctx;
ZERO_STRUCT(guid);
- if (!guidstr) return guid;
+ v = ldb_msg_find_ldb_val(msg, attr);
+ if (!v) return guid;
- status = GUID_from_string(guidstr, &guid);
+ mem_ctx = talloc_named_const(NULL, 0, "samdb_result_guid");
+ if (!mem_ctx) return guid;
+ status = ndr_pull_struct_blob(v, mem_ctx, &guid,
+ (ndr_pull_flags_fn_t)ndr_pull_GUID);
+ talloc_free(mem_ctx);
if (!NT_STATUS_IS_OK(status)) {
- ZERO_STRUCT(guid);
return guid;
}
@@ -685,17 +690,17 @@ static NTSTATUS _samdb_allocate_next_id(struct ldb_context *sam_ldb, TALLOC_CTX
els[1].flags = LDB_FLAG_MOD_ADD;
els[1].name = els[0].name;
- vals[0].data = talloc_asprintf(mem_ctx, "%u", *id);
+ vals[0].data = (uint8_t *)talloc_asprintf(mem_ctx, "%u", *id);
if (!vals[0].data) {
return NT_STATUS_NO_MEMORY;
}
- vals[0].length = strlen(vals[0].data);
+ vals[0].length = strlen((const char *)vals[0].data);
- vals[1].data = talloc_asprintf(mem_ctx, "%u", (*id)+1);
+ vals[1].data = (uint8_t *)talloc_asprintf(mem_ctx, "%u", (*id)+1);
if (!vals[1].data) {
return NT_STATUS_NO_MEMORY;
}
- vals[1].length = strlen(vals[1].data);
+ vals[1].length = strlen((const char *)vals[1].data);
ret = ldb_modify(sam_ldb, &msg);
if (ret != 0) {
@@ -764,6 +769,7 @@ int samdb_msg_add_dom_sid(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, stru
return ldb_msg_add_value(sam_ldb, msg, attr_name, &v);
}
+
/*
add a delete element operation to a message
*/
@@ -971,18 +977,20 @@ int samdb_msg_set_ldaptime(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, str
*/
int samdb_add(struct ldb_context *sam_ldb, 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) {
+ int ret;
+ struct ldb_val v;
+ NTSTATUS status;
+ struct GUID guid = GUID_random();
+
+ status = ndr_push_struct_blob(&v, mem_ctx, &guid,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ if (!NT_STATUS_IS_OK(status)) {
return -1;
}
- samdb_msg_add_string(sam_ldb, mem_ctx, msg, "objectGUID", guidstr);
- samdb_msg_set_ldaptime(sam_ldb, mem_ctx, msg, "whenCreated", now);
+ ret = ldb_msg_add_value(sam_ldb, msg, "objectGUID", &v);
+ if (ret != 0) return ret;
+
return ldb_add(sam_ldb, msg);
}