mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
r15582: Commit some forgotten stuff that have been setting on my private tree fro long
This commit is contained in:
parent
b79092d7ee
commit
7c050b541e
@ -1,7 +1,7 @@
|
||||
/*
|
||||
ldb database library
|
||||
|
||||
Copyright (C) Simo Sorce 2004
|
||||
Copyright (C) Simo Sorce 2004-2006
|
||||
Copyright (C) Andrew Bartlett <abartlet@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 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
|
||||
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 @@ static int objectguid_request(struct ldb_module *module, struct ldb_request *req
|
||||
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);
|
||||
|
||||
|
@ -859,20 +859,12 @@ static int samldb_add_async(struct ldb_module *module, struct ldb_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
*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);
|
||||
|
||||
|
@ -724,3 +724,20 @@ void ldb_dump_results(struct ldb_context *ldb, struct ldb_result *result, FILE *
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -625,11 +625,11 @@ struct ldb_search {
|
||||
};
|
||||
|
||||
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 *ldb_msg_diff(struct ldb_context *ldb,
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user