mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
s4-drs: Using dsdb_msg_add_guid() utility function
Uses the dsdb_msg_add_guid() to add any kind of GUID attribute to a ldb_message in several places of samba4 code. Signed-off-by: Andrew Tridgell <tridge@samba.org>
This commit is contained in:
parent
0003b5fad1
commit
71e29cbf56
@ -31,6 +31,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "ldb_module.h"
|
||||
#include "dsdb/samdb/samdb.h"
|
||||
#include "librpc/gen_ndr/ndr_misc.h"
|
||||
#include "param/param.h"
|
||||
|
||||
@ -136,10 +137,8 @@ static int objectguid_add(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;
|
||||
uint64_t seq_num;
|
||||
enum ndr_err_code ndr_err;
|
||||
int ret;
|
||||
time_t t = time(NULL);
|
||||
struct og_context *ac;
|
||||
@ -174,15 +173,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
|
||||
/* a new GUID */
|
||||
guid = GUID_random();
|
||||
|
||||
ndr_err = ndr_push_struct_blob(&v, msg,
|
||||
lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
|
||||
&guid,
|
||||
(ndr_push_flags_fn_t)ndr_push_GUID);
|
||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
|
||||
ret = ldb_msg_add_value(msg, "objectGUID", &v, NULL);
|
||||
ret = dsdb_msg_add_guid(msg, &guid, "objectGUID");
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -411,7 +411,6 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
|
||||
struct ldb_message *msg;
|
||||
const DATA_BLOB *guid_blob;
|
||||
struct GUID guid;
|
||||
struct ldb_val guid_value;
|
||||
struct replPropertyMetaDataBlob nmd;
|
||||
struct ldb_val nmd_value;
|
||||
const struct GUID *our_invocation_id;
|
||||
@ -580,15 +579,6 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
|
||||
}
|
||||
|
||||
/* generated NDR encoded values */
|
||||
ndr_err = ndr_push_struct_blob(&guid_value, msg,
|
||||
NULL,
|
||||
&guid,
|
||||
(ndr_push_flags_fn_t)ndr_push_GUID);
|
||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||
ldb_oom(ldb);
|
||||
talloc_free(ac);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
ndr_err = ndr_push_struct_blob(&nmd_value, msg,
|
||||
lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
|
||||
&nmd,
|
||||
@ -602,7 +592,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
|
||||
/*
|
||||
* add the autogenerated values
|
||||
*/
|
||||
ret = ldb_msg_add_value(msg, "objectGUID", &guid_value, NULL);
|
||||
ret = dsdb_msg_add_guid(msg, &guid, "objectGUID");
|
||||
if (ret != LDB_SUCCESS) {
|
||||
ldb_oom(ldb);
|
||||
talloc_free(ac);
|
||||
|
@ -1161,21 +1161,10 @@ static int samldb_fill_object(struct samldb_ctx *ac, const char *type)
|
||||
}
|
||||
|
||||
if (!ldb_msg_find_element(ac->msg, "schemaIDGUID")) {
|
||||
enum ndr_err_code ndr_err;
|
||||
struct ldb_val guid_value;
|
||||
struct GUID guid;
|
||||
/* a new GUID */
|
||||
guid = GUID_random();
|
||||
/* generated NDR encoded values */
|
||||
ndr_err = ndr_push_struct_blob(&guid_value, ac->msg,
|
||||
NULL,
|
||||
&guid,
|
||||
(ndr_push_flags_fn_t)ndr_push_GUID);
|
||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||
ldb_oom(ldb);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
ret = ldb_msg_add_value(ac->msg, "schemaIDGUID", &guid_value, NULL);
|
||||
ret = dsdb_msg_add_guid(ac->msg, &guid, "schemaIDGUID");
|
||||
if (ret != LDB_SUCCESS) {
|
||||
ldb_oom(ldb);
|
||||
return ret;
|
||||
@ -1211,21 +1200,10 @@ static int samldb_fill_object(struct samldb_ctx *ac, const char *type)
|
||||
if (ret != LDB_SUCCESS) return ret;
|
||||
|
||||
if (!ldb_msg_find_element(ac->msg, "schemaIDGUID")) {
|
||||
enum ndr_err_code ndr_err;
|
||||
struct ldb_val guid_value;
|
||||
struct GUID guid;
|
||||
/* a new GUID */
|
||||
guid = GUID_random();
|
||||
/* generated NDR encoded values */
|
||||
ndr_err = ndr_push_struct_blob(&guid_value, ac->msg,
|
||||
NULL,
|
||||
&guid,
|
||||
(ndr_push_flags_fn_t)ndr_push_GUID);
|
||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||
ldb_oom(ldb);
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
ret = ldb_msg_add_value(ac->msg, "schemaIDGUID", &guid_value, NULL);
|
||||
ret = dsdb_msg_add_guid(ac->msg, &guid, "schemaIDGUID");
|
||||
if (ret != LDB_SUCCESS) {
|
||||
ldb_oom(ldb);
|
||||
return ret;
|
||||
|
@ -399,14 +399,7 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry)
|
||||
|
||||
memcpy(&guid, digest, sizeof(struct GUID));
|
||||
|
||||
ndr_err = ndr_push_struct_blob(&schemaIdGuid, ctx, NULL, &guid,
|
||||
(ndr_push_flags_fn_t)ndr_push_GUID);
|
||||
|
||||
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (ldb_msg_add_value(msg, "schemaIdGuid", &schemaIdGuid, NULL) != 0) {
|
||||
if (dsdb_msg_add_guid(msg, &guid, "schemaIdGuid") != 0) {
|
||||
goto failed;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user