summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/dsdb/samdb/samdb.c152
-rw-r--r--source4/include/db_wrap.h7
-rw-r--r--source4/ldap_server/ldap_hacked_ldb.c52
-rw-r--r--source4/ldap_server/ldap_rootdse.c2
-rw-r--r--source4/ldap_server/ldap_simple_ldb.c38
-rw-r--r--source4/lib/db_wrap.c38
-rw-r--r--source4/lib/ldb/common/ldb.c11
-rw-r--r--source4/lib/ldb/common/ldb_modules.c103
-rw-r--r--source4/lib/ldb/include/ldb.h6
-rw-r--r--source4/lib/ldb/include/ldb_private.h8
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c11
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c11
-rw-r--r--source4/lib/ldb/man/man3/ldb.yo2
-rw-r--r--source4/lib/ldb/modules/schema.c40
-rw-r--r--source4/lib/ldb/modules/skel.c16
-rw-r--r--source4/lib/ldb/modules/timestamps.c134
-rw-r--r--source4/lib/ldb/tools/ldbadd.c2
-rw-r--r--source4/lib/ldb/tools/ldbdel.c2
-rw-r--r--source4/lib/ldb/tools/ldbedit.c2
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c2
-rw-r--r--source4/lib/ldb/tools/ldbrename.c2
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c2
-rw-r--r--source4/lib/ldb/tools/ldbtest.c6
-rw-r--r--source4/lib/registry/reg_backend_ldb.c15
-rw-r--r--source4/libnet/libnet_join.c2
-rw-r--r--source4/nbt_server/wins/winsdb.c12
-rw-r--r--source4/nbt_server/wins/winsdb.h2
-rw-r--r--source4/passdb/secrets.c4
-rw-r--r--source4/rpc_server/lsa/dcesrv_lsa.c118
-rw-r--r--source4/rpc_server/netlogon/schannel_state.c30
30 files changed, 421 insertions, 411 deletions
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index 9c05e26f22..4cebcfc692 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -31,7 +31,7 @@
connect to the SAM database
return an opaque context pointer on success, or NULL on failure
*/
-struct ldb_wrap *samdb_connect(TALLOC_CTX *mem_ctx)
+struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx)
{
return ldb_wrap_connect(mem_ctx, lp_sam_url(), 0, NULL);
}
@@ -39,7 +39,7 @@ struct ldb_wrap *samdb_connect(TALLOC_CTX *mem_ctx)
/*
search the sam for the specified attributes - varargs variant
*/
-int samdb_search(struct ldb_wrap *sam_ctx,
+int samdb_search(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *basedn,
struct ldb_message ***res,
@@ -50,7 +50,7 @@ int samdb_search(struct ldb_wrap *sam_ctx,
int count;
va_start(ap, format);
- count = gendb_search_v(sam_ctx->ldb, mem_ctx, basedn, res, attrs, format, ap);
+ count = gendb_search_v(sam_ldb, mem_ctx, basedn, res, attrs, format, ap);
va_end(ap);
return count;
@@ -60,7 +60,7 @@ int samdb_search(struct ldb_wrap *sam_ctx,
search the sam for the specified attributes in a specific domain, filter on
objectSid being in domain_sid.
*/
-int samdb_search_domain(struct ldb_wrap *sam_ctx,
+int samdb_search_domain(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *basedn,
struct ldb_message ***res,
@@ -72,7 +72,7 @@ int samdb_search_domain(struct ldb_wrap *sam_ctx,
int i, count;
va_start(ap, format);
- count = gendb_search_v(sam_ctx->ldb, mem_ctx, basedn, res, attrs,
+ count = gendb_search_v(sam_ldb, mem_ctx, basedn, res, attrs,
format, ap);
va_end(ap);
@@ -101,16 +101,16 @@ int samdb_search_domain(struct ldb_wrap *sam_ctx,
/*
free up a search result
*/
-int samdb_search_free(struct ldb_wrap *sam_ctx,
+int samdb_search_free(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx, struct ldb_message **res)
{
- return ldb_search_free(sam_ctx->ldb, res);
+ return ldb_search_free(sam_ldb, res);
}
/*
search the sam for a single string attribute in exactly 1 record
*/
-const char *samdb_search_string_v(struct ldb_wrap *sam_ctx,
+const char *samdb_search_string_v(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *basedn,
const char *attr_name,
@@ -120,13 +120,13 @@ const char *samdb_search_string_v(struct ldb_wrap *sam_ctx,
const char * const attrs[2] = { attr_name, NULL };
struct ldb_message **res = NULL;
- count = gendb_search_v(sam_ctx->ldb, mem_ctx, basedn, &res, attrs, format, ap);
+ count = gendb_search_v(sam_ldb, mem_ctx, basedn, &res, attrs, format, ap);
if (count > 1) {
DEBUG(1,("samdb: search for %s %s not single valued (count=%d)\n",
attr_name, format, count));
}
if (count != 1) {
- samdb_search_free(sam_ctx, mem_ctx, res);
+ samdb_search_free(sam_ldb, mem_ctx, res);
return NULL;
}
@@ -137,7 +137,7 @@ const char *samdb_search_string_v(struct ldb_wrap *sam_ctx,
/*
search the sam for a single string attribute in exactly 1 record
*/
-const char *samdb_search_string(struct ldb_wrap *sam_ctx,
+const char *samdb_search_string(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *basedn,
const char *attr_name,
@@ -147,7 +147,7 @@ const char *samdb_search_string(struct ldb_wrap *sam_ctx,
const char *str;
va_start(ap, format);
- str = samdb_search_string_v(sam_ctx, mem_ctx, basedn, attr_name, format, ap);
+ str = samdb_search_string_v(sam_ldb, mem_ctx, basedn, attr_name, format, ap);
va_end(ap);
return str;
@@ -156,7 +156,7 @@ const char *samdb_search_string(struct ldb_wrap *sam_ctx,
/*
return the count of the number of records in the sam matching the query
*/
-int samdb_search_count(struct ldb_wrap *sam_ctx,
+int samdb_search_count(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *basedn,
const char *format, ...) _PRINTF_ATTRIBUTE(4,5)
@@ -167,7 +167,7 @@ int samdb_search_count(struct ldb_wrap *sam_ctx,
int ret;
va_start(ap, format);
- ret = gendb_search_v(sam_ctx->ldb, mem_ctx, basedn, &res, attrs, format, ap);
+ ret = gendb_search_v(sam_ldb, mem_ctx, basedn, &res, attrs, format, ap);
va_end(ap);
return ret;
@@ -177,7 +177,7 @@ int samdb_search_count(struct ldb_wrap *sam_ctx,
/*
search the sam for a single integer attribute in exactly 1 record
*/
-uint_t samdb_search_uint(struct ldb_wrap *sam_ctx,
+uint_t samdb_search_uint(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
uint_t default_value,
const char *basedn,
@@ -190,7 +190,7 @@ uint_t samdb_search_uint(struct ldb_wrap *sam_ctx,
const char * const attrs[2] = { attr_name, NULL };
va_start(ap, format);
- count = gendb_search_v(sam_ctx->ldb, mem_ctx, basedn, &res, attrs, format, ap);
+ count = gendb_search_v(sam_ldb, mem_ctx, basedn, &res, attrs, format, ap);
va_end(ap);
if (count != 1) {
@@ -203,7 +203,7 @@ uint_t samdb_search_uint(struct ldb_wrap *sam_ctx,
/*
search the sam for a single signed 64 bit integer attribute in exactly 1 record
*/
-int64_t samdb_search_int64(struct ldb_wrap *sam_ctx,
+int64_t samdb_search_int64(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
int64_t default_value,
const char *basedn,
@@ -216,7 +216,7 @@ int64_t samdb_search_int64(struct ldb_wrap *sam_ctx,
const char * const attrs[2] = { attr_name, NULL };
va_start(ap, format);
- count = gendb_search_v(sam_ctx->ldb, mem_ctx, basedn, &res, attrs, format, ap);
+ count = gendb_search_v(sam_ldb, mem_ctx, basedn, &res, attrs, format, ap);
va_end(ap);
if (count != 1) {
@@ -230,7 +230,7 @@ int64_t samdb_search_int64(struct ldb_wrap *sam_ctx,
search the sam for multipe records each giving a single string attribute
return the number of matches, or -1 on error
*/
-int samdb_search_string_multiple(struct ldb_wrap *sam_ctx,
+int samdb_search_string_multiple(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *basedn,
const char ***strs,
@@ -243,7 +243,7 @@ int samdb_search_string_multiple(struct ldb_wrap *sam_ctx,
struct ldb_message **res = NULL;
va_start(ap, format);
- count = gendb_search_v(sam_ctx->ldb, mem_ctx, basedn, &res, attrs, format, ap);
+ count = gendb_search_v(sam_ldb, mem_ctx, basedn, &res, attrs, format, ap);
va_end(ap);
if (count <= 0) {
@@ -255,14 +255,14 @@ int samdb_search_string_multiple(struct ldb_wrap *sam_ctx,
if (res[i]->num_elements != 1) {
DEBUG(1,("samdb: search for %s %s not single valued\n",
attr_name, format));
- samdb_search_free(sam_ctx, mem_ctx, res);
+ samdb_search_free(sam_ldb, mem_ctx, res);
return -1;
}
}
*strs = talloc_array(mem_ctx, const char *, count+1);
if (! *strs) {
- samdb_search_free(sam_ctx, mem_ctx, res);
+ samdb_search_free(sam_ldb, mem_ctx, res);
return -1;
}
@@ -386,7 +386,7 @@ uint64_t samdb_result_uint64(struct ldb_message *msg, const char *attr, uint64_t
construct the allow_password_change field from the PwdLastSet attribute and the
domain password settings
*/
-NTTIME samdb_result_allow_password_change(struct ldb_wrap *sam_ctx,
+NTTIME samdb_result_allow_password_change(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *domain_dn,
struct ldb_message *msg,
@@ -399,7 +399,7 @@ NTTIME samdb_result_allow_password_change(struct ldb_wrap *sam_ctx,
return 0;
}
- minPwdAge = samdb_search_int64(sam_ctx, mem_ctx, 0, NULL,
+ minPwdAge = samdb_search_int64(sam_ldb, mem_ctx, 0, NULL,
"minPwdAge", "dn=%s", domain_dn);
/* yes, this is a -= not a += as minPwdAge is stored as the negative
@@ -413,7 +413,7 @@ NTTIME samdb_result_allow_password_change(struct ldb_wrap *sam_ctx,
construct the force_password_change field from the PwdLastSet attribute and the
domain password settings
*/
-NTTIME samdb_result_force_password_change(struct ldb_wrap *sam_ctx,
+NTTIME samdb_result_force_password_change(struct ldb_context *sam_ldb,
TALLOC_CTX *mem_ctx,
const char *domain_dn,
struct ldb_message *msg,
@@ -426,7 +426,7 @@ NTTIME samdb_result_force_password_change(struct ldb_wrap *sam_ctx,
return 0;
}
- maxPwdAge = samdb_search_int64(sam_ctx, mem_ctx, 0, NULL, "maxPwdAge", "dn=%s", domain_dn);
+ maxPwdAge = samdb_search_int64(sam_ldb, mem_ctx, 0, NULL, "maxPwdAge", "dn=%s", domain_dn);
if (maxPwdAge == 0) {
return 0;
} else {
@@ -577,7 +577,7 @@ uint16_t samdb_result_acct_flags(struct ldb_message *msg, const char *attr)
/*
copy from a template record to a message
*/
-int samdb_copy_template(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx,
+int samdb_copy_template(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
struct ldb_message *msg, const char *expression)
{
struct ldb_message **res, *t;
@@ -585,7 +585,7 @@ int samdb_copy_template(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx,
/* pull the template record */
- ret = samdb_search(sam_ctx, mem_ctx, NULL, &res, NULL, "%s", expression);
+ ret = samdb_search(sam_ldb, mem_ctx, NULL, &res, NULL, "%s", expression);
if (ret != 1) {
DEBUG(1,("samdb: ERROR: template '%s' matched %d records\n",
expression, ret));
@@ -612,7 +612,7 @@ int samdb_copy_template(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx,
strcasecmp((char *)el->values[j].data, "secretTemplate") == 0)) {
continue;
}
- samdb_msg_add_string(sam_ctx, mem_ctx, msg, el->name,
+ samdb_msg_add_string(sam_ldb, mem_ctx, msg, el->name,
(char *)el->values[j].data);
}
}
@@ -625,7 +625,7 @@ int samdb_copy_template(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx,
allocate a new id, attempting to do it atomically
return 0 on failure, the id on success
*/
-static NTSTATUS _samdb_allocate_next_id(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, const char *dn,
+static NTSTATUS _samdb_allocate_next_id(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, const char *dn,
const char *attr, uint32_t *id)
{
struct ldb_message msg;
@@ -634,7 +634,7 @@ static NTSTATUS _samdb_allocate_next_id(struct ldb_wrap *sam_ctx, TALLOC_CTX *me
struct ldb_val vals[2];
struct ldb_message_element els[2];
- str = samdb_search_string(sam_ctx, mem_ctx, NULL, attr, "dn=%s", dn);
+ str = samdb_search_string(sam_ldb, mem_ctx, NULL, attr, "dn=%s", dn);
if (!str) {
DEBUG(1,("id not found at %s %s\n", dn, attr));
return NT_STATUS_OBJECT_NAME_INVALID;
@@ -681,7 +681,7 @@ static NTSTATUS _samdb_allocate_next_id(struct ldb_wrap *sam_ctx, TALLOC_CTX *me
}
vals[1].length = strlen(vals[1].data);
- ret = ldb_modify(sam_ctx->ldb, &msg);
+ ret = ldb_modify(sam_ldb, &msg);
if (ret != 0) {
return NT_STATUS_UNEXPECTED_IO_ERROR;
}
@@ -695,7 +695,7 @@ static NTSTATUS _samdb_allocate_next_id(struct ldb_wrap *sam_ctx, TALLOC_CTX *me
allocate a new id, attempting to do it atomically
return 0 on failure, the id on success
*/
-NTSTATUS samdb_allocate_next_id(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, const char *dn, const char *attr,
+NTSTATUS samdb_allocate_next_id(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, const char *dn, const char *attr,
uint32_t *id)
{
int tries = 10;
@@ -704,7 +704,7 @@ NTSTATUS samdb_allocate_next_id(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, c
/* we need to try multiple times to cope with two account
creations at the same time */
while (tries--) {
- status = _samdb_allocate_next_id(sam_ctx, mem_ctx, dn, attr, id);
+ status = _samdb_allocate_next_id(sam_ldb, mem_ctx, dn, attr, id);
if (!NT_STATUS_EQUAL(NT_STATUS_UNEXPECTED_IO_ERROR, status)) {
break;
}
@@ -721,7 +721,7 @@ NTSTATUS samdb_allocate_next_id(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, c
/*
add a string element to a message
*/
-int samdb_msg_add_string(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_string(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, const char *str)
{
char *s = talloc_strdup(mem_ctx, str);
@@ -729,13 +729,13 @@ int samdb_msg_add_string(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
if (s == NULL || a == NULL) {
return -1;
}
- return ldb_msg_add_string(sam_ctx->ldb, msg, a, s);
+ return ldb_msg_add_string(sam_ldb, msg, a, s);
}
/*
add a delete element operation to a message
*/
-int samdb_msg_add_delete(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_delete(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name)
{
char *a = talloc_strdup(mem_ctx, attr_name);
@@ -744,13 +744,13 @@ int samdb_msg_add_delete(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
}
/* we use an empty replace rather than a delete, as it allows for
samdb_replace() to be used everywhere */
- return ldb_msg_add_empty(sam_ctx->ldb, msg, a, LDB_FLAG_MOD_REPLACE);
+ return ldb_msg_add_empty(sam_ldb, msg, a, LDB_FLAG_MOD_REPLACE);
}
/*
add a add attribute value to a message
*/
-int samdb_msg_add_addval(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_addval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, const char *value)
{
struct ldb_message_element *el;
@@ -762,7 +762,7 @@ int samdb_msg_add_addval(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
v = talloc_strdup(mem_ctx, value);
if (v == NULL)
return -1;
- ret = ldb_msg_add_string(sam_ctx->ldb, msg, a, v);
+ ret = ldb_msg_add_string(sam_ldb, msg, a, v);
if (ret != 0)
return ret;
el = ldb_msg_find_element(msg, a);
@@ -775,7 +775,7 @@ int samdb_msg_add_addval(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
/*
add a delete attribute value to a message
*/
-int samdb_msg_add_delval(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_delval(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, const char *value)
{
struct ldb_message_element *el;
@@ -787,7 +787,7 @@ int samdb_msg_add_delval(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
v = talloc_strdup(mem_ctx, value);
if (v == NULL)
return -1;
- ret = ldb_msg_add_string(sam_ctx->ldb, msg, a, v);
+ ret = ldb_msg_add_string(sam_ldb, msg, a, v);
if (ret != 0)
return ret;
el = ldb_msg_find_element(msg, a);
@@ -800,37 +800,37 @@ int samdb_msg_add_delval(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
/*
add a uint_t element to a message
*/
-int samdb_msg_add_uint(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_uint(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, uint_t v)
{
const char *s = talloc_asprintf(mem_ctx, "%u", v);
- return samdb_msg_add_string(sam_ctx, mem_ctx, msg, attr_name, s);
+ return samdb_msg_add_string(sam_ldb, mem_ctx, msg, attr_name, s);
}
/*
add a (signed) int64_t element to a message
*/
-int samdb_msg_add_int64(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_int64(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, int64_t v)
{
const char *s = talloc_asprintf(mem_ctx, "%lld", v);
- return samdb_msg_add_string(sam_ctx, mem_ctx, msg, attr_name, s);
+ return samdb_msg_add_string(sam_ldb, mem_ctx, msg, attr_name, s);
}
/*
add a uint64_t element to a message
*/
-int samdb_msg_add_uint64(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_uint64(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, uint64_t v)
{
const char *s = talloc_asprintf(mem_ctx, "%llu", v);
- return samdb_msg_add_string(sam_ctx, mem_ctx, msg, attr_name, s);
+ return samdb_msg_add_string(sam_ldb, mem_ctx, msg, attr_name, s);
}
/*
add a samr_Password element to a message
*/
-int samdb_msg_add_hash(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_hash(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, struct samr_Password *hash)
{
struct ldb_val val;
@@ -839,13 +839,13 @@ int samdb_msg_add_hash(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb
return -1;
}
val.length = 16;
- return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(sam_ldb, msg, attr_name, &val);
}
/*
add a samr_Password array to a message
*/
-int samdb_msg_add_hashes(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_hashes(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, struct samr_Password *hashes, uint_t count)
{
struct ldb_val val;
@@ -858,43 +858,43 @@ int samdb_msg_add_hashes(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
for (i=0;i<count;i++) {
memcpy(i*16 + (char *)val.data, hashes[i].hash, 16);
}
- return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(sam_ldb, msg, attr_name, &val);
}
/*
add a acct_flags element to a message
*/
-int samdb_msg_add_acct_flags(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_acct_flags(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, uint32_t v)
{
- return samdb_msg_add_uint(sam_ctx, mem_ctx, msg, attr_name, samdb_acb2uf(v));
+ return samdb_msg_add_uint(sam_ldb, mem_ctx, msg, attr_name, samdb_acb2uf(v));
}
/*
add a logon_hours element to a message
*/
-int samdb_msg_add_logon_hours(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_logon_hours(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, struct samr_LogonHours *hours)
{
struct ldb_val val;
val.length = hours->units_per_week / 8;
val.data = hours->bits;
- return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, &val);
+ return ldb_msg_add_value(sam_ldb, msg, attr_name, &val);
}
/*
add a general value element to a message
*/
-int samdb_msg_add_value(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_add_value(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, const struct ldb_val *val)
{
- return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, val);
+ return ldb_msg_add_value(sam_ldb, msg, attr_name, val);
}
/*
sets a general value element to a message
*/
-int samdb_msg_set_value(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_set_value(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, const struct ldb_val *val)
{
struct ldb_message_element *el;
@@ -903,13 +903,13 @@ int samdb_msg_set_value(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ld
if (el) {
el->num_values = 0;
}
- return ldb_msg_add_value(sam_ctx->ldb, msg, attr_name, val);
+ return ldb_msg_add_value(sam_ldb, msg, attr_name, val);
}
/*
set a string element in a message
*/
-int samdb_msg_set_string(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_set_string(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, const char *str)
{
struct ldb_message_element *el;
@@ -918,26 +918,26 @@ int samdb_msg_set_string(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct l
if (el) {
el->num_values = 0;
}
- return samdb_msg_add_string(sam_ctx, mem_ctx, msg, attr_name, str);
+ return samdb_msg_add_string(sam_ldb, mem_ctx, msg, attr_name, str);
}
/*
set a ldaptime element in a message
*/
-int samdb_msg_set_ldaptime(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+int samdb_msg_set_ldaptime(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
const char *attr_name, time_t t)
{
char *str = ldap_timestring(mem_ctx, t);
if (!str) {
return -1;
}
- return samdb_msg_set_string(sam_ctx, mem_ctx, msg, attr_name, str);
+ return samdb_msg_set_string(sam_ldb, mem_ctx, msg, attr_name, str);
}
/*
add a record
*/
-int samdb_add(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg)
+int samdb_add(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg)
{
struct GUID guid;
const char *guidstr;
@@ -949,34 +949,34 @@ int samdb_add(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message
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);
+ samdb_msg_add_string(sam_ldb, mem_ctx, msg, "objectGUID", guidstr);
+ samdb_msg_set_ldaptime(sam_ldb, mem_ctx, msg, "whenCreated", now);
+ samdb_msg_set_ldaptime(sam_ldb, mem_ctx, msg, "whenChanged", now);
+ return ldb_add(sam_ldb, msg);
}
/*
delete a record
*/
-int samdb_delete(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, const char *dn)
+int samdb_delete(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, const char *dn)
{
- return ldb_delete(sam_ctx->ldb, dn);
+ return ldb_delete(sam_ldb, dn);
}
/*
modify a record
*/
-int samdb_modify(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg)
+int samdb_modify(struct ldb_context *sam_ldb, 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);
+ samdb_msg_set_ldaptime(sam_ldb, mem_ctx, msg, "whenChanged", now);
+ return ldb_modify(sam_ldb, msg);
}
/*
replace elements in a record
*/
-int samdb_replace(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_message *msg)
+int samdb_replace(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg)
{
int i;
@@ -986,7 +986,7 @@ int samdb_replace(struct ldb_wrap *sam_ctx, TALLOC_CTX *mem_ctx, struct ldb_mess
}
/* modify the samdb record */
- return samdb_modify(sam_ctx, mem_ctx, msg);
+ return samdb_modify(sam_ldb, mem_ctx, msg);
}
/*
diff --git a/source4/include/db_wrap.h b/source4/include/db_wrap.h
index c336461dbe..48e1bbc9e1 100644
--- a/source4/include/db_wrap.h
+++ b/source4/include/db_wrap.h
@@ -20,13 +20,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-struct ldb_wrap {
- struct ldb_context *ldb;
-
- const char *url;
- struct ldb_wrap *next, *prev;
-};
-
struct tdb_wrap {
struct tdb_context *tdb;
diff --git a/source4/ldap_server/ldap_hacked_ldb.c b/source4/ldap_server/ldap_hacked_ldb.c
index 419a00c458..0829ae7753 100644
--- a/source4/ldap_server/ldap_hacked_ldb.c
+++ b/source4/ldap_server/ldap_hacked_ldb.c
@@ -53,7 +53,7 @@
static NTSTATUS convert_values(TALLOC_CTX *mem_ctx,
struct ldb_message_element *elem,
struct ldap_attribute *attrs,
- struct ldb_wrap *samdb,
+ struct ldb_context *samdb,
const char **dn,
struct ldap_SearchRequest *r)
{
@@ -130,7 +130,7 @@ DEBUG(0, (__location__": convert_values(ncname): nc dn = '%s'\n", nc_filter));
/* first the NC stuff */
- count = ldb_search(samdb->ldb, "", LDB_SCOPE_BASE, nc_filter, s_attrs, &res);
+ count = ldb_search(samdb, "", LDB_SCOPE_BASE, nc_filter, s_attrs, &res);
if (count != 1) {
DEBUG(0, (__location__": convert_values(ncname): nc_count: %d \n", count));
return NT_STATUS_FOOBAR;
@@ -158,7 +158,7 @@ DEBUG(0, (__location__": convert_values(ncname): dn='%s'\n",*dn));
dom_filter = talloc_asprintf(mem_ctx, "(dn=%s)", dom_dn);
DEBUG(0, (__location__": convert_values(ncname): dom dn = '%s'\n", dom_filter));
- count = ldb_search(samdb->ldb, "", LDB_SCOPE_BASE, dom_filter, s_attrs, &res);
+ count = ldb_search(samdb, "", LDB_SCOPE_BASE, dom_filter, s_attrs, &res);
if (count != 1) {
DEBUG(0, (__location__": convert_values(ncname): dom_count: %d \n", count));
return NT_STATUS_OK;
@@ -281,7 +281,7 @@ static NTSTATUS hacked_wellknown_Search(struct ldapsrv_partition *partition, str
}
static NTSTATUS hacked_Search(struct ldapsrv_partition *partition, struct ldapsrv_call *call,
- struct ldap_SearchRequest *r, struct ldb_wrap *samdb)
+ struct ldap_SearchRequest *r, struct ldb_context *samdb)
{
NTSTATUS status;
void *local_ctx;
@@ -334,7 +334,7 @@ static NTSTATUS hacked_Search(struct ldapsrv_partition *partition, struct ldapsr
}
DEBUG(0,("hacked basedn: %s\n", basedn_str));
DEBUGADD(0,("hacked filter: %s\n", r->filter));
- count = ldb_search(samdb->ldb, basedn_str, scope, r->filter, attrs, &res);
+ count = ldb_search(samdb, basedn_str, scope, r->filter, attrs, &res);
talloc_steal(samdb, res);
if (count < 1) {
@@ -450,11 +450,11 @@ queue_reply2:
} else if (count == 0) {
DEBUG(10,("hacked_Search: no results\n"));
result = LDAP_NO_SUCH_OBJECT;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
} else if (count == -1) {
DEBUG(10,("hacked_Search: error\n"));
result = LDAP_OTHER;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
done = &done_r->msg.r.SearchResultDone;
@@ -473,7 +473,7 @@ static NTSTATUS hldb_Search(struct ldapsrv_partition *partition, struct ldapsrv_
{
NTSTATUS status;
void *local_ctx;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
#if 0
struct ldap_dn *basedn;
struct ldap_Result *done;
@@ -531,7 +531,7 @@ static NTSTATUS hldb_Search(struct ldapsrv_partition *partition, struct ldapsrv_
attrs[i] = NULL;
}
- count = ldb_search(samdb->ldb, basedn->dn, scope, r->filter, attrs, &res);
+ count = ldb_search(samdb, basedn->dn, scope, r->filter, attrs, &res);
talloc_steal(samdb, res);
if (count < 1) {
@@ -591,11 +591,11 @@ reply:
} else if (count == 0) {
DEBUG(10,("hldb_Search: no results\n"));
result = LDAP_NO_SUCH_OBJECT;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
} else if (count == -1) {
DEBUG(10,("hldb_Search: error\n"));
result = LDAP_OTHER;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
@@ -619,7 +619,7 @@ static NTSTATUS hldb_Add(struct ldapsrv_partition *partition, struct ldapsrv_cal
struct ldap_Result *add_result;
struct ldapsrv_reply *add_reply;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
struct ldb_message *msg = NULL;
int result = LDAP_SUCCESS;
const char *errstr = NULL;
@@ -686,7 +686,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(add_reply);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_add(samdb->ldb, msg);
+ ldb_ret = ldb_add(samdb, msg);
if (ldb_ret == 0) {
DEBUG(0,("hldb_Add: added: '%s'\n", msg->dn));
result = LDAP_SUCCESS;
@@ -696,7 +696,7 @@ reply:
* or if the object was not found, return the most probable error
*/
result = LDAP_OPERATIONS_ERROR;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
@@ -719,7 +719,7 @@ static NTSTATUS hldb_Del(struct ldapsrv_partition *partition, struct ldapsrv_cal
struct ldap_Result *del_result;
struct ldapsrv_reply *del_reply;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
const char *errstr = NULL;
int result = LDAP_SUCCESS;
@@ -739,7 +739,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(del_reply);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_delete(samdb->ldb, dn->dn);
+ ldb_ret = ldb_delete(samdb, dn->dn);
if (ldb_ret == 0) {
result = LDAP_SUCCESS;
errstr = NULL;
@@ -748,7 +748,7 @@ reply:
* or if the object was not found, return the most probable error
*/
result = LDAP_NO_SUCH_OBJECT;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
@@ -771,7 +771,7 @@ static NTSTATUS hldb_Modify(struct ldapsrv_partition *partition, struct ldapsrv_
struct ldap_Result *modify_result;
struct ldapsrv_reply *modify_reply;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
struct ldb_message *msg = NULL;
int result = LDAP_SUCCESS;
const char *errstr = NULL;
@@ -849,7 +849,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(modify_reply);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_modify(samdb->ldb, msg);
+ ldb_ret = ldb_modify(samdb, msg);
if (ldb_ret == 0) {
result = LDAP_SUCCESS;
errstr = NULL;
@@ -859,7 +859,7 @@ reply:
*/
result = LDAP_ATTRIBUTE_OR_VALUE_EXISTS;
result = LDAP_OPERATIONS_ERROR;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
if (strcmp("Type or value exists", errstr) ==0){
result = LDAP_ATTRIBUTE_OR_VALUE_EXISTS;
}
@@ -886,7 +886,7 @@ static NTSTATUS hldb_Compare(struct ldapsrv_partition *partition, struct ldapsrv
struct ldap_Result *compare;
struct ldapsrv_reply *compare_r;
int result = LDAP_SUCCESS;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
struct ldb_message **res = NULL;
const char *attrs[1];
const char *errstr = NULL;
@@ -915,7 +915,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(compare_r);
if (result == LDAP_SUCCESS) {
- count = ldb_search(samdb->ldb, dn->dn, LDB_SCOPE_BASE, filter, attrs, &res);
+ count = ldb_search(samdb, dn->dn, LDB_SCOPE_BASE, filter, attrs, &res);
talloc_steal(samdb, res);
if (count == 1) {
DEBUG(10,("hldb_Compare: matched\n"));
@@ -931,7 +931,7 @@ reply:
DEBUG(10,("hldb_Compare: %d results: %s\n", count, errstr));
} else if (count == -1) {
result = LDAP_OTHER;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
DEBUG(10,("hldb_Compare: error: %s\n", errstr));
}
}
@@ -954,7 +954,7 @@ static NTSTATUS hldb_ModifyDN(struct ldapsrv_partition *partition, struct ldapsr
struct ldap_Result *modifydn;
struct ldapsrv_reply *modifydn_r;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
const char *errstr = NULL;
int result = LDAP_SUCCESS;
const char *newdn = NULL;
@@ -1020,7 +1020,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(modifydn_r);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_rename(samdb->ldb, olddn->dn, newdn);
+ ldb_ret = ldb_rename(samdb, olddn->dn, newdn);
if (ldb_ret == 0) {
result = LDAP_SUCCESS;
errstr = NULL;
@@ -1029,7 +1029,7 @@ reply:
* or if the object was not found, return the most probable error
*/
result = LDAP_NO_SUCH_OBJECT;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
diff --git a/source4/ldap_server/ldap_rootdse.c b/source4/ldap_server/ldap_rootdse.c
index 3ab1ef03af..63206436a1 100644
--- a/source4/ldap_server/ldap_rootdse.c
+++ b/source4/ldap_server/ldap_rootdse.c
@@ -59,7 +59,7 @@ static void rootdse_db_debug(void *context, enum ldb_debug_level level, const ch
static int rootdse_db_destructor(void *ctx)
{
struct rootdse_db_context *rd_ctx = ctx;
- ldb_close(rd_ctx->ldb);
+ talloc_free(rd_ctx->ldb);
*(rd_ctx->static_ptr) = NULL;
return 0;
}
diff --git a/source4/ldap_server/ldap_simple_ldb.c b/source4/ldap_server/ldap_simple_ldb.c
index 7fd86269cc..905acc10f1 100644
--- a/source4/ldap_server/ldap_simple_ldb.c
+++ b/source4/ldap_server/ldap_simple_ldb.c
@@ -45,7 +45,7 @@ static NTSTATUS sldb_Search(struct ldapsrv_partition *partition, struct ldapsrv_
struct ldap_SearchResEntry *ent;
struct ldapsrv_reply *ent_r, *done_r;
int result = LDAP_SUCCESS;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
struct ldb_message **res = NULL;
int i, j, y, count = 0;
enum ldb_scope scope = LDB_SCOPE_DEFAULT;
@@ -90,7 +90,7 @@ static NTSTATUS sldb_Search(struct ldapsrv_partition *partition, struct ldapsrv_
attrs[i] = NULL;
}
- count = ldb_search(samdb->ldb, basedn->dn, scope, r->filter, attrs, &res);
+ count = ldb_search(samdb, basedn->dn, scope, r->filter, attrs, &res);
talloc_steal(samdb, res);
for (i=0; i < count; i++) {
@@ -143,11 +143,11 @@ reply:
} else if (count == 0) {
DEBUG(10,("sldb_Search: no results\n"));
result = LDAP_NO_SUCH_OBJECT;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
} else if (count == -1) {
DEBUG(10,("sldb_Search: error\n"));
result = LDAP_OTHER;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
@@ -170,7 +170,7 @@ static NTSTATUS sldb_Add(struct ldapsrv_partition *partition, struct ldapsrv_cal
struct ldap_Result *add_result;
struct ldapsrv_reply *add_reply;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
struct ldb_message *msg = NULL;
int result = LDAP_SUCCESS;
const char *errstr = NULL;
@@ -237,7 +237,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(add_reply);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_add(samdb->ldb, msg);
+ ldb_ret = ldb_add(samdb, msg);
if (ldb_ret == 0) {
result = LDAP_SUCCESS;
errstr = NULL;
@@ -246,7 +246,7 @@ reply:
* or if the object was not found, return the most probable error
*/
result = LDAP_OPERATIONS_ERROR;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
@@ -269,7 +269,7 @@ static NTSTATUS sldb_Del(struct ldapsrv_partition *partition, struct ldapsrv_cal
struct ldap_Result *del_result;
struct ldapsrv_reply *del_reply;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
const char *errstr = NULL;
int result = LDAP_SUCCESS;
@@ -289,7 +289,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(del_reply);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_delete(samdb->ldb, dn->dn);
+ ldb_ret = ldb_delete(samdb, dn->dn);
if (ldb_ret == 0) {
result = LDAP_SUCCESS;
errstr = NULL;
@@ -298,7 +298,7 @@ reply:
* or if the object was not found, return the most probable error
*/
result = LDAP_NO_SUCH_OBJECT;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
@@ -321,7 +321,7 @@ static NTSTATUS sldb_Modify(struct ldapsrv_partition *partition, struct ldapsrv_
struct ldap_Result *modify_result;
struct ldapsrv_reply *modify_reply;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
struct ldb_message *msg = NULL;
int result = LDAP_SUCCESS;
const char *errstr = NULL;
@@ -399,7 +399,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(modify_reply);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_modify(samdb->ldb, msg);
+ ldb_ret = ldb_modify(samdb, msg);
if (ldb_ret == 0) {
result = LDAP_SUCCESS;
errstr = NULL;
@@ -408,7 +408,7 @@ reply:
* or if the object was not found, return the most probable error
*/
result = LDAP_OPERATIONS_ERROR;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
@@ -431,7 +431,7 @@ static NTSTATUS sldb_Compare(struct ldapsrv_partition *partition, struct ldapsrv
struct ldap_Result *compare;
struct ldapsrv_reply *compare_r;
int result = LDAP_SUCCESS;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
struct ldb_message **res = NULL;
const char *attrs[1];
const char *errstr = NULL;
@@ -460,7 +460,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(compare_r);
if (result == LDAP_SUCCESS) {
- count = ldb_search(samdb->ldb, dn->dn, LDB_SCOPE_BASE, filter, attrs, &res);
+ count = ldb_search(samdb, dn->dn, LDB_SCOPE_BASE, filter, attrs, &res);
talloc_steal(samdb, res);
if (count == 1) {
DEBUG(10,("sldb_Compare: matched\n"));
@@ -476,7 +476,7 @@ reply:
DEBUG(10,("sldb_Compare: %d results: %s\n", count, errstr));
} else if (count == -1) {
result = LDAP_OTHER;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
DEBUG(10,("sldb_Compare: error: %s\n", errstr));
}
}
@@ -499,7 +499,7 @@ static NTSTATUS sldb_ModifyDN(struct ldapsrv_partition *partition, struct ldapsr
struct ldap_Result *modifydn;
struct ldapsrv_reply *modifydn_r;
int ldb_ret;
- struct ldb_wrap *samdb;
+ struct ldb_context *samdb;
const char *errstr = NULL;
int result = LDAP_SUCCESS;
const char *newdn = NULL;
@@ -565,7 +565,7 @@ reply:
NT_STATUS_HAVE_NO_MEMORY(modifydn_r);
if (result == LDAP_SUCCESS) {
- ldb_ret = ldb_rename(samdb->ldb, olddn->dn, newdn);
+ ldb_ret = ldb_rename(samdb, olddn->dn, newdn);
if (ldb_ret == 0) {
result = LDAP_SUCCESS;
errstr = NULL;
@@ -574,7 +574,7 @@ reply:
* or if the object was not found, return the most probable error
*/
result = LDAP_NO_SUCH_OBJECT;
- errstr = ldb_errstring(samdb->ldb);
+ errstr = ldb_errstring(samdb);
}
}
diff --git a/source4/lib/db_wrap.c b/source4/lib/db_wrap.c
index 0ec1e378e6..a3a9ee9b86 100644
--- a/source4/lib/db_wrap.c
+++ b/source4/lib/db_wrap.c
@@ -33,6 +33,13 @@
#include "lib/ldb/include/ldb.h"
#include "db_wrap.h"
+struct ldb_wrap {
+ struct ldb_context *ldb;
+
+ const char *url;
+ struct ldb_wrap *next, *prev;
+};
+
static struct ldb_wrap *ldb_list;
static struct tdb_wrap *tdb_list;
@@ -55,53 +62,52 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
free(s);
}
-
/* destroy the last connection to a ldb */
static int ldb_wrap_destructor(void *ctx)
{
struct ldb_wrap *w = ctx;
- ldb_close(w->ldb);
DLIST_REMOVE(ldb_list, w);
return 0;
}
/*
wrapped connection to a ldb database
- to close just talloc_free() the ldb_wrap pointer
+ to close just talloc_free() the returned ldb_context
*/
-struct ldb_wrap *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
+struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
const char *url,
unsigned int flags,
const char *options[])
{
+ struct ldb_context *ldb;
struct ldb_wrap *w;
- for (w=ldb_list;w;w=w->next) {
+ for (w = ldb_list; w; w = w->next) {
if (strcmp(url, w->url) == 0) {
- return talloc_reference(mem_ctx, w);
+ return talloc_reference(mem_ctx, w->ldb);
}
}
- w = talloc(mem_ctx, struct ldb_wrap);
- if (w == NULL) {
+ ldb = ldb_connect(url, flags, options);
+ if (ldb == NULL) {
return NULL;
}
- w->url = talloc_strdup(w, url);
-
- w->ldb = ldb_connect(url, flags, options);
- if (w->ldb == NULL) {
- talloc_free(w);
+ w = talloc(ldb, struct ldb_wrap);
+ if (w == NULL) {
+ talloc_free(ldb);
return NULL;
}
- talloc_steal(w, w->ldb);
+
+ w->ldb = ldb;
+ w->url = talloc_strdup(w, url);
talloc_set_destructor(w, ldb_wrap_destructor);
- ldb_set_debug(w->ldb, ldb_wrap_debug, NULL);
+ ldb_set_debug(ldb, ldb_wrap_debug, NULL);
DLIST_ADD(ldb_list, w);
- return w;
+ return ldb;
}
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 0fb371011f..40616c5963 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -69,7 +69,7 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags,
}
if (ldb_load_modules(ldb_ctx, options) != 0) {
- ldb_close(ldb_ctx);
+ talloc_free(ldb_ctx);
errno = EINVAL;
return NULL;
}
@@ -78,15 +78,6 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags,
}
/*
- close the connection to the database
-*/
-int ldb_close(struct ldb_context *ldb)
-{
- return ldb->modules->ops->close(ldb->modules);
-}
-
-
-/*
search the database given a LDAP-like search expression
return the number of records found, or -1 on error
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 22d1ce112e..f8162aee8c 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -41,6 +41,10 @@
#include <sys/stat.h>
#include <unistd.h>
+#ifdef HAVE_DLOPEN_DISABLED
+#include <dlfcn.h>
+#endif
+
#define LDB_MODULE_PREFIX "modules"
#define LDB_MODULE_PREFIX_LEN 7
#define LDB_MODULE_SEP ':'
@@ -49,14 +53,15 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
{
struct ldb_module *current;
char **modules;
- char *p, *q;
- int pn, i;
+ int mnum, i;
/* find out which modules we are requested to activate */
modules = NULL;
- pn = 0;
+ mnum = 0;
if (options) {
+ char *q, *p;
+
for (i = 0; options[i] != NULL; i++) {
if (strncmp(options[i], LDB_MODULE_PREFIX,
LDB_MODULE_PREFIX_LEN) == 0) {
@@ -68,13 +73,13 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
do {
*p = '\0';
q = p + 1;
- pn++;
- modules = talloc_realloc(ldb, modules, char *, pn);
+ mnum++;
+ modules = talloc_realloc(ldb, modules, char *, mnum);
if (!modules) {
- ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in register_modules()\n");
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in ldb_load_modules()\n");
return -1;
}
- modules[pn - 1] = q;
+ modules[mnum - 1] = q;
} while ((p = strchr(q, LDB_MODULE_SEP)));
}
}
@@ -83,9 +88,10 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
if (!modules && strcmp("ldap", ldb->modules->ops->name)) {
/* no modules in the options, look for @MODULES in the
db (not for ldap) */
- int ret, j, k;
- const char * const attrs[] = { "@MODULE" , NULL};
+ int ret;
+ const char * const attrs[] = { "@LIST" , NULL};
struct ldb_message **msg = NULL;
+ char *modstr, *c, *p;
ret = ldb_search(ldb, "", LDB_SCOPE_BASE, "dn=@MODULES", attrs, &msg);
if (ret == 0) {
@@ -100,6 +106,7 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
return -1;
}
+/*
for (j = 0; j < msg[0]->num_elements; j++) {
for (k = 0; k < msg[0]->elements[j].num_values; k++) {
pn++;
@@ -115,12 +122,58 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
}
}
}
+*/
+ modstr = msg[0]->elements[0].values[0].data;
+ for (c = modstr, mnum = 0; c != NULL; mnum++) {
+ c = strchr(c, ',');
+ if (c != NULL) {
+ c++;
+ if (*c == '\0') { /* avoid failing if the modules string lasts with ',' */
+ break;
+ }
+ }
+ }
+
+
+ modules = talloc_array(ldb, char *, mnum);
+ if ( ! modules ) {
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "Out of Memory in ldb_load_modules()\n");
+ return -1;
+ }
+
+ for (p = c = modstr, i = 0; mnum > i; i++) {
+ c = strchr(p, ',');
+ if (c) {
+ *c = '\0';
+ }
+ /* modules are seeked in inverse order. Lets place them as an admin would think the right order is */
+ modules[mnum - i - 1] = talloc_strdup(modules, p);
+ p = c + 1;
+ }
}
talloc_free(msg);
}
if (modules) {
- for (i = 0; i < pn; i++) {
+ for (i = 0; i < mnum; i++) {
+#ifdef HAVE_DLOPEN_DISABLED
+ void *handle;
+ ldb_module_init_function init;
+ struct stat st;
+ char *filename;
+ const char *errstr;
+#endif
+
+ if (strcmp(modules[i], "schema") == 0) {
+ current = schema_module_init(ldb, options);
+ if (!current) {
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
+ return -1;
+ }
+ DLIST_ADD(ldb->modules, current);
+ continue;
+ }
+
if (strcmp(modules[i], "timestamps") == 0) {
current = timestamps_module_init(ldb, options);
if (!current) {
@@ -131,8 +184,8 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
continue;
}
- if (strcmp(modules[i], "schema") == 0) {
- current = schema_module_init(ldb, options);
+ if (strcmp(modules[i], "samldb") == 0) {
+ current = samldb_module_init(ldb, options);
if (!current) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "function 'init_module' in %s fails\n", modules[i]);
return -1;
@@ -142,18 +195,18 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
}
#ifdef HAVE_DLOPEN_DISABLED
- {
- void *handle;
- ldb_module_init_function init;
- struct stat st;
- const char *errstr;
+ filename = talloc_asprintf(ldb, "%s.so", modules[i]);
+ if (!filename) {
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "Talloc failed!\n");
+ return -1;
+ }
- if (stat(modules[i], &st) < 0) {
+ if (stat(filename, &st) < 0) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "Required module [%s] not found, bailing out!\n", modules[i]);
return -1;
}
- handle = dlopen(modules[i], RTLD_LAZY);
+ handle = dlopen(filename, RTLD_LAZY);
if (!handle) {
ldb_debug(ldb, LDB_DEBUG_FATAL, "Error loading module %s [%s]\n", modules[i], dlerror());
@@ -174,10 +227,9 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
return -1;
}
DLIST_ADD(ldb->modules, current);
- }
#else
- ldb_debug(ldb, LDB_DEBUG_FATAL, "Required module [%s] not found, bailing out!\n", modules[i]);
- return -1;
+ ldb_debug(ldb, LDB_DEBUG_FATAL, "Required module [%s] not found, bailing out!\n", modules[i]);
+ return -1;
#endif
}
}
@@ -188,13 +240,6 @@ int ldb_load_modules(struct ldb_context *ldb, const char *options[])
/*
helper functions to call the next module in chain
*/
-int ldb_next_close(struct ldb_module *module)
-{
- if (!module->next) {
- return -1;
- }
- return module->next->ops->close(module->next);
-}
int ldb_next_search(struct ldb_module *module,
const char *base,
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 09b4cbf84a..0eb661d7ce 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -159,12 +159,6 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags,
const char *options[]);
/*
- close the connection to the database
-*/
-int ldb_close(struct ldb_context *ldb);
-
-
-/*
search the database given a LDAP-like search expression
return the number of records found, or -1 on error
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index 426da5ccae..a370a80299 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -55,7 +55,6 @@ struct ldb_module {
*/
struct ldb_module_ops {
const char *name;
- int (*close)(struct ldb_module *);
int (*search)(struct ldb_module *, const char *, enum ldb_scope,
const char *, const char * const [], struct ldb_message ***);
int (*search_free)(struct ldb_module *, struct ldb_message **);
@@ -68,9 +67,6 @@ struct ldb_module_ops {
const char * (*errstring)(struct ldb_module *);
};
-/* the modules init function */
-typedef struct ldb_module *(*ldb_module_init_function)(void);
-
/*
every ldb connection is started by establishing a ldb_context
*/
@@ -82,10 +78,12 @@ struct ldb_context {
struct ldb_debug_ops debug_ops;
};
+/* the modules init function */
+typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]);
+
/* The following definitions come from lib/ldb/common/ldb_modules.c */
int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
-int ldb_next_close(struct ldb_module *module);
int ldb_next_search(struct ldb_module *module,
const char *base,
enum ldb_scope scope,
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 46ea1a9e33..dc392dd56b 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -68,16 +68,6 @@ static const char *lldb_option_find(const struct lldb_private *lldb, const char
#endif
/*
- close/free the connection
-*/
-static int lldb_close(struct ldb_module *module)
-{
- struct ldb_context *ldb = module->ldb;
- talloc_free(ldb);
- return 0;
-}
-
-/*
rename a record
*/
static int lldb_rename(struct ldb_module *module, const char *olddn, const char *newdn)
@@ -468,7 +458,6 @@ static const char *lldb_errstring(struct ldb_module *module)
static const struct ldb_module_ops lldb_ops = {
"ldap",
- lldb_close,
lldb_search,
lldb_search_free,
lldb_add,
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 07a9fa8866..204eaf9d3c 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -780,16 +780,6 @@ failed:
return -1;
}
-/*
- close database
-*/
-static int ltdb_close(struct ldb_module *module)
-{
- struct ldb_context *ldb = module->ldb;
- talloc_free(ldb);
- return 0;
-}
-
/*
return extended error information
@@ -806,7 +796,6 @@ static const char *ltdb_errstring(struct ldb_module *module)
static const struct ldb_module_ops ltdb_ops = {
"tdb",
- ltdb_close,
ltdb_search,
ltdb_search_free,
ltdb_add,
diff --git a/source4/lib/ldb/man/man3/ldb.yo b/source4/lib/ldb/man/man3/ldb.yo
index ce8a590fbc..8d7a60ccf2 100644
--- a/source4/lib/ldb/man/man3/ldb.yo
+++ b/source4/lib/ldb/man/man3/ldb.yo
@@ -64,8 +64,6 @@ formatted input
dit(bf(ldb_connect(3))) connect to a ldb backend
-dit(bf(ldb_close(3))) close a connection to a ldb backend
-
dit(bf(ldb_search(3))) perform a database search
dit(bf(ldb_search_free(3))) free the results of a ldb_search
diff --git a/source4/lib/ldb/modules/schema.c b/source4/lib/ldb/modules/schema.c
index 2921bdc68b..ef766b55ee 100644
--- a/source4/lib/ldb/modules/schema.c
+++ b/source4/lib/ldb/modules/schema.c
@@ -297,12 +297,6 @@ static int get_attr_list_recursive(struct ldb_module *module, struct schema_stru
return 0;
}
-/* close */
-static int schema_close(struct ldb_module *module)
-{
- return ldb_next_close(module);
-}
-
/* search */
static int schema_search(struct ldb_module *module, const char *base,
enum ldb_scope scope, const char *expression,
@@ -371,18 +365,6 @@ static int schema_add_record(struct ldb_module *module, const struct ldb_message
return -1;
}
- /* check we are not trying to delete a required attribute */
- /* TODO: consider multivalued attrs */
- if ((attr->flags & SCHEMA_FLAG_MOD_DELETE) != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
- "Trying to delete the required attribute %s.\n",
- attr->name);
-
- data->error_string = "Objectclass violation, a required attribute cannot be removed";
- talloc_free(entry_structs);
- return -1;
- }
-
/* mark the attribute as checked */
attr->flags = SCHEMA_FLAG_CHECKED;
}
@@ -477,6 +459,18 @@ static int schema_modify_record(struct ldb_module *module, const struct ldb_mess
return -1;
}
+ /* check we are not trying to delete a required attribute */
+ /* TODO: consider multivalued attrs */
+ if ((attr->flags & SCHEMA_FLAG_MOD_DELETE) != 0) {
+ ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ "Trying to delete the required attribute %s.\n",
+ attr->name);
+
+ data->error_string = "Objectclass violation, a required attribute cannot be removed";
+ talloc_free(entry_structs);
+ return -1;
+ }
+
/* mark the attribute as checked */
attr->flags = SCHEMA_FLAG_CHECKED;
}
@@ -544,9 +538,15 @@ static const char *schema_errstring(struct ldb_module *module)
return ldb_next_errstring(module);
}
+static int schema_destructor(void *module_ctx)
+{
+ struct ldb_module *ctx = module_ctx;
+ /* put your clean-up functions here */
+ return 0;
+}
+
static const struct ldb_module_ops schema_ops = {
"schema",
- schema_close,
schema_search,
schema_search_free,
schema_add_record,
@@ -584,5 +584,7 @@ struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *optio
ctx->prev = ctx->next = NULL;
ctx->ops = &schema_ops;
+ talloc_set_destructor (ctx, schema_destructor);
+
return ctx;
}
diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c
index afafe1bbd9..882a776819 100644
--- a/source4/lib/ldb/modules/skel.c
+++ b/source4/lib/ldb/modules/skel.c
@@ -36,12 +36,6 @@
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
-/* close */
-static int skel_close(struct ldb_module *module)
-{
- return ldb_next_close(module);
-}
-
/* search */
static int skel_search(struct ldb_module *module, const char *base,
enum ldb_scope scope, const char *expression,
@@ -98,9 +92,15 @@ static const char *skel_errstring(struct ldb_module *module)
return ldb_next_errstring(module);
}
+static int skel_destructor(void *module_ctx)
+{
+ struct ldb_module *ctx = module_ctx;
+ /* put your clean-up functions here */
+ return 0;
+}
+
static const struct ldb_module_ops skel_ops = {
"skel",
- skel_close,
skel_search,
skel_search_free,
skel_add_record,
@@ -129,5 +129,7 @@ struct ldb_module *skel_plugin_init(struct ldb_context *ldb, const char *options
ctx->private_data = NULL;
ctx->ops = &skel_ops;
+ talloc_set_destructor (ctx, skel_destructor);
+
return ctx;
}
diff --git a/source4/lib/ldb/modules/timestamps.c b/source4/lib/ldb/modules/timestamps.c
index 1deeeb218b..dec564bf66 100644
--- a/source4/lib/ldb/modules/timestamps.c
+++ b/source4/lib/ldb/modules/timestamps.c
@@ -41,12 +41,6 @@ struct private_data {
const char *error_string;
};
-static int timestamps_close(struct ldb_module *module)
-{
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_close\n");
- return ldb_next_close(module);
-}
-
static int timestamps_search(struct ldb_module *module, const char *base,
enum ldb_scope scope, const char *expression,
const char * const *attrs, struct ldb_message ***res)
@@ -106,41 +100,43 @@ static int timestamps_add_record(struct ldb_module *module, const struct ldb_mes
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_add_record\n");
- if (msg->dn[0] != '@') { /* do not manipulate our control entries */
- timeval = time(NULL);
- tm = gmtime(&timeval);
- if (!tm) {
- return -1;
- }
+ if (msg->dn[0] == '@') { /* do not manipulate our control entries */
+ return ldb_next_add_record(module, msg);
+ }
- msg2 = talloc(module, struct ldb_message);
- if (!msg2) {
- return -1;
- }
+ timeval = time(NULL);
+ tm = gmtime(&timeval);
+ if (!tm) {
+ return -1;
+ }
- /* formatted like: 20040408072012.0Z */
- timestr = talloc_asprintf(msg2, "%04u%02u%02u%02u%02u%02u.0Z",
- tm->tm_year+1900, tm->tm_mon+1,
- tm->tm_mday, tm->tm_hour, tm->tm_min,
- tm->tm_sec);
- if (!timestr) {
- return -1;
- }
+ msg2 = talloc(module, struct ldb_message);
+ if (!msg2) {
+ return -1;
+ }
- msg2->dn = msg->dn;
- msg2->num_elements = msg->num_elements;
- msg2->private_data = msg->private_data;
- msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements);
- for (i = 0; i < msg2->num_elements; i++) {
- msg2->elements[i] = msg->elements[i];
- }
+ /* formatted like: 20040408072012.0Z */
+ timestr = talloc_asprintf(msg2, "%04u%02u%02u%02u%02u%02u.0Z",
+ tm->tm_year+1900, tm->tm_mon+1,
+ tm->tm_mday, tm->tm_hour, tm->tm_min,
+ tm->tm_sec);
+ if (!timestr) {
+ return -1;
+ }
- add_time_element(module, msg2, "createTimestamp", timestr, LDB_FLAG_MOD_ADD);
- add_time_element(module, msg2, "modifyTimestamp", timestr, LDB_FLAG_MOD_ADD);
- add_time_element(module, msg2, "whenCreated", timestr, LDB_FLAG_MOD_ADD);
- add_time_element(module, msg2, "whenChanged", timestr, LDB_FLAG_MOD_ADD);
+ msg2->dn = msg->dn;
+ msg2->num_elements = msg->num_elements;
+ msg2->private_data = msg->private_data;
+ msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements);
+ for (i = 0; i < msg2->num_elements; i++) {
+ msg2->elements[i] = msg->elements[i];
}
+ add_time_element(module, msg2, "createTimestamp", timestr, LDB_FLAG_MOD_ADD);
+ add_time_element(module, msg2, "modifyTimestamp", timestr, LDB_FLAG_MOD_ADD);
+ add_time_element(module, msg2, "whenCreated", timestr, LDB_FLAG_MOD_ADD);
+ add_time_element(module, msg2, "whenChanged", timestr, LDB_FLAG_MOD_ADD);
+
if (msg2) {
ret = ldb_next_add_record(module, msg2);
talloc_free(msg2);
@@ -162,40 +158,42 @@ static int timestamps_modify_record(struct ldb_module *module, const struct ldb_
ldb_debug(module->ldb, LDB_DEBUG_TRACE, "timestamps_modify_record\n");
- if (msg->dn[0] != '@') { /* do not manipulate our control entries */
- timeval = time(NULL);
- tm = gmtime(&timeval);
- if (!tm) {
- return -1;
- }
+ if (msg->dn[0] == '@') { /* do not manipulate our control entries */
+ return ldb_next_modify_record(module, msg);
+ }
- msg2 = talloc(module, struct ldb_message);
- if (!msg2) {
- return -1;
- }
+ timeval = time(NULL);
+ tm = gmtime(&timeval);
+ if (!tm) {
+ return -1;
+ }
- /* formatted like: 20040408072012.0Z */
- timestr = talloc_asprintf(msg2,
- "%04u%02u%02u%02u%02u%02u.0Z",
- tm->tm_year+1900, tm->tm_mon+1,
- tm->tm_mday, tm->tm_hour, tm->tm_min,
- tm->tm_sec);
- if (!timestr) {
- return -1;
- }
+ msg2 = talloc(module, struct ldb_message);
+ if (!msg2) {
+ return -1;
+ }
- msg2->dn = msg->dn;
- msg2->num_elements = msg->num_elements;
- msg2->private_data = msg->private_data;
- msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements);
- for (i = 0; i < msg2->num_elements; i++) {
- msg2->elements[i] = msg->elements[i];
- }
+ /* formatted like: 20040408072012.0Z */
+ timestr = talloc_asprintf(msg2,
+ "%04u%02u%02u%02u%02u%02u.0Z",
+ tm->tm_year+1900, tm->tm_mon+1,
+ tm->tm_mday, tm->tm_hour, tm->tm_min,
+ tm->tm_sec);
+ if (!timestr) {
+ return -1;
+ }
- add_time_element(module, msg2, "modifyTimestamp", timestr, LDB_FLAG_MOD_REPLACE);
- add_time_element(module, msg2, "whenChanged", timestr, LDB_FLAG_MOD_REPLACE);
+ msg2->dn = msg->dn;
+ msg2->num_elements = msg->num_elements;
+ msg2->private_data = msg->private_data;
+ msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements);
+ for (i = 0; i < msg2->num_elements; i++) {
+ msg2->elements[i] = msg->elements[i];
}
+ add_time_element(module, msg2, "modifyTimestamp", timestr, LDB_FLAG_MOD_REPLACE);
+ add_time_element(module, msg2, "whenChanged", timestr, LDB_FLAG_MOD_REPLACE);
+
if (msg2) {
ret = ldb_next_modify_record(module, msg2);
talloc_free(msg2);
@@ -247,9 +245,15 @@ static const char *timestamps_errstring(struct ldb_module *module)
return ldb_next_errstring(module);
}
+static int timestamps_destructor(void *module_ctx)
+{
+ struct ldb_module *ctx = module_ctx;
+ /* put your clean-up functions here */
+ return 0;
+}
+
static const struct ldb_module_ops timestamps_ops = {
"timestamps",
- timestamps_close,
timestamps_search,
timestamps_search_free,
timestamps_add_record,
@@ -288,5 +292,7 @@ struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *o
ctx->prev = ctx->next = NULL;
ctx->ops = &timestamps_ops;
+ talloc_set_destructor (ctx, timestamps_destructor);
+
return ctx;
}
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index 927debc65e..41273a08da 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -153,7 +153,7 @@ static int process_file(struct ldb_context *ldb, FILE *f)
}
}
- ldb_close(ldb);
+ talloc_free(ldb);
printf("Added %d records with %d failures\n", count, failures);
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index 2241a0b823..72540db07a 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -146,7 +146,7 @@ static void usage(void)
}
}
- ldb_close(ldb);
+ talloc_free(ldb);
return 0;
}
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 20cb7da810..b9f82c282a 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -434,6 +434,6 @@ static void usage(void)
}
}
- ldb_close(ldb);
+ talloc_free(ldb);
return 0;
}
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index 97dec1050e..78baa0e36c 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -156,7 +156,7 @@ static int process_file(struct ldb_context *ldb, FILE *f)
}
}
- ldb_close(ldb);
+ talloc_free(ldb);
printf("Modified %d records with %d failures\n", count, failures);
diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c
index ba870b0a45..273c792584 100644
--- a/source4/lib/ldb/tools/ldbrename.c
+++ b/source4/lib/ldb/tools/ldbrename.c
@@ -112,7 +112,7 @@ static void usage(void)
argv[0], argv[1], ldb_errstring(ldb));
}
- ldb_close(ldb);
+ talloc_free(ldb);
return ret;
}
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index f764b28557..8d435e7661 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -176,6 +176,6 @@ static int do_search(struct ldb_context *ldb,
ret = do_search(ldb, basedn, scope, argv[0], attrs);
}
- ldb_close(ldb);
+ talloc_free(ldb);
return ret;
}
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index a166447aae..86f39d4606 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -323,8 +323,8 @@ static void start_test_index(struct ldb_context **ldb)
exit(1);
}
- if (ldb_close(*ldb) != 0) {
- printf("ldb_close failed - %s\n", ldb_errstring(*ldb));
+ if (talloc_free(*ldb) != 0) {
+ printf("failed to free/close ldb database");
exit(1);
}
@@ -427,7 +427,7 @@ static void usage(void)
start_test_index(&ldb);
- ldb_close(ldb);
+ talloc_free(ldb);
return 0;
}
diff --git a/source4/lib/registry/reg_backend_ldb.c b/source4/lib/registry/reg_backend_ldb.c
index 9f44f92888..7e63b14245 100644
--- a/source4/lib/registry/reg_backend_ldb.c
+++ b/source4/lib/registry/reg_backend_ldb.c
@@ -30,10 +30,10 @@ struct ldb_key_data
int subkey_count, value_count;
};
-static int ldb_close_hive (void *_hive)
+static int ldb_free_hive (void *_hive)
{
struct registry_hive *hive = _hive;
- ldb_close (hive->backend_data);
+ talloc_free(hive->backend_data);
return 0;
}
@@ -231,9 +231,8 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h, const ch
static WERROR ldb_open_hive(struct registry_hive *hive, struct registry_key **k)
{
- struct ldb_context *c;
struct ldb_key_data *kd;
- struct ldb_wrap *wrap;
+ struct ldb_context *wrap;
if (!hive->location) return WERR_INVALID_PARAM;
wrap = ldb_wrap_connect(hive, hive->location, 0, NULL);
@@ -243,14 +242,12 @@ static WERROR ldb_open_hive(struct registry_hive *hive, struct registry_key **k)
return WERR_FOOBAR;
}
- c = wrap->ldb;
-
- ldb_set_debug_stderr(c);
- hive->backend_data = c;
+ ldb_set_debug_stderr(wrap);
+ hive->backend_data = wrap;
*k = talloc_zero(hive, struct registry_key);
talloc_set_destructor (*k, reg_close_ldb_key);
- talloc_set_destructor (hive, ldb_close_hive);
+ talloc_set_destructor (hive, ldb_free_hive);
(*k)->name = talloc_strdup(*k, "");
(*k)->backend_data = kd = talloc_zero(*k, struct ldb_key_data);
kd->dn = talloc_strdup(*k, "hive=");
diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c
index 9257b8db3d..2a9311b663 100644
--- a/source4/libnet/libnet_join.c
+++ b/source4/libnet/libnet_join.c
@@ -330,7 +330,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
NTSTATUS status;
int ret;
- struct ldb_wrap *ldb;
+ struct ldb_context *ldb;
union libnet_JoinDomain r2;
const char *base_dn = "cn=Primary Domains";
const struct ldb_val *prior_secret;
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 4b547bc644..f2156af1c2 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -33,7 +33,7 @@
static BOOL winsdb_save_version(struct wins_server *winssrv)
{
int i, ret = 0;
- struct ldb_context *ldb = winssrv->wins_db->ldb;
+ struct ldb_context *ldb = winssrv->wins_db;
struct ldb_message *msg = ldb_msg_new(winssrv);
if (msg == NULL) goto failed;
@@ -101,7 +101,7 @@ struct winsdb_record *winsdb_load(struct wins_server *winssrv,
if (expr == NULL) goto failed;
/* find the record in the WINS database */
- ret = ldb_search(winssrv->wins_db->ldb, NULL, LDB_SCOPE_ONELEVEL, expr, NULL, &res);
+ ret = ldb_search(winssrv->wins_db, NULL, LDB_SCOPE_ONELEVEL, expr, NULL, &res);
if (res != NULL) {
talloc_steal(tmp_ctx, res);
}
@@ -155,7 +155,7 @@ static struct ldb_message *winsdb_message(struct wins_server *winssrv,
struct winsdb_record *rec, TALLOC_CTX *mem_ctx)
{
int i, ret=0;
- struct ldb_context *ldb = winssrv->wins_db->ldb;
+ struct ldb_context *ldb = winssrv->wins_db;
struct ldb_message *msg = ldb_msg_new(mem_ctx);
if (msg == NULL) goto failed;
@@ -183,7 +183,7 @@ failed:
*/
uint8_t winsdb_add(struct wins_server *winssrv, struct winsdb_record *rec)
{
- struct ldb_context *ldb = winssrv->wins_db->ldb;
+ struct ldb_context *ldb = winssrv->wins_db;
struct ldb_message *msg;
TALLOC_CTX *tmp_ctx = talloc_new(winssrv);
int ret;
@@ -210,7 +210,7 @@ failed:
*/
uint8_t winsdb_modify(struct wins_server *winssrv, struct winsdb_record *rec)
{
- struct ldb_context *ldb = winssrv->wins_db->ldb;
+ struct ldb_context *ldb = winssrv->wins_db;
struct ldb_message *msg;
TALLOC_CTX *tmp_ctx = talloc_new(winssrv);
int ret;
@@ -243,7 +243,7 @@ failed:
*/
uint8_t winsdb_delete(struct wins_server *winssrv, struct winsdb_record *rec)
{
- struct ldb_context *ldb = winssrv->wins_db->ldb;
+ struct ldb_context *ldb = winssrv->wins_db;
TALLOC_CTX *tmp_ctx = talloc_new(winssrv);
int ret;
const char *dn;
diff --git a/source4/nbt_server/wins/winsdb.h b/source4/nbt_server/wins/winsdb.h
index 6d395461c6..454bef3e3b 100644
--- a/source4/nbt_server/wins/winsdb.h
+++ b/source4/nbt_server/wins/winsdb.h
@@ -40,7 +40,7 @@ struct winsdb_record {
struct wins_server {
/* wins server database handle */
- struct ldb_wrap *wins_db;
+ struct ldb_context *wins_db;
uint32_t min_ttl;
uint32_t max_ttl;
diff --git a/source4/passdb/secrets.c b/source4/passdb/secrets.c
index d202326d5c..b7d05dd98c 100644
--- a/source4/passdb/secrets.c
+++ b/source4/passdb/secrets.c
@@ -177,10 +177,10 @@ void secrets_named_mutex_release(const char *name, size_t *p_ref_count)
/*
connect to the schannel ldb
*/
-struct ldb_wrap *secrets_db_connect(TALLOC_CTX *mem_ctx)
+struct ldb_context *secrets_db_connect(TALLOC_CTX *mem_ctx)
{
char *path;
- struct ldb_wrap *ldb;
+ struct ldb_context *ldb;
path = private_path(mem_ctx, "secrets.ldb");
if (!path) {
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index a8f2af12ed..2e1a621eee 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -46,7 +46,7 @@ enum lsa_handle {
*/
struct lsa_policy_state {
struct dcesrv_handle *handle;
- struct ldb_wrap *sam_ctx;
+ struct ldb_context *sam_ldb;
struct sidmap_context *sidmap;
uint32_t access_mask;
const char *domain_dn;
@@ -77,7 +77,7 @@ struct lsa_secret_state {
struct lsa_policy_state *policy;
uint32_t access_mask;
const char *secret_dn;
- struct ldb_wrap *sam_ctx;
+ struct ldb_context *sam_ldb;
BOOL global;
};
@@ -122,7 +122,7 @@ static NTSTATUS lsa_Delete(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_c
DCESRV_PULL_HANDLE(h, r->in.handle, DCESRV_HANDLE_ANY);
if (h->wire_handle.handle_type == LSA_HANDLE_SECRET) {
struct lsa_secret_state *secret_state = h->data;
- ret = samdb_delete(secret_state->sam_ctx, mem_ctx, secret_state->secret_dn);
+ ret = samdb_delete(secret_state->sam_ldb, mem_ctx, secret_state->secret_dn);
talloc_free(h);
if (ret != 0) {
return NT_STATUS_INVALID_HANDLE;
@@ -131,7 +131,7 @@ static NTSTATUS lsa_Delete(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_c
return NT_STATUS_OK;
} else if (h->wire_handle.handle_type == LSA_HANDLE_TRUSTED_DOMAIN) {
struct lsa_trusted_domain_state *trusted_domain_state = h->data;
- ret = samdb_delete(trusted_domain_state->policy->sam_ctx, mem_ctx,
+ ret = samdb_delete(trusted_domain_state->policy->sam_ldb, mem_ctx,
trusted_domain_state->trusted_domain_dn);
talloc_free(h);
if (ret != 0) {
@@ -229,8 +229,8 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
}
/* make sure the sam database is accessible */
- state->sam_ctx = samdb_connect(state);
- if (state->sam_ctx == NULL) {
+ state->sam_ldb = samdb_connect(state);
+ if (state->sam_ldb == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@@ -242,7 +242,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
/* work out the domain_dn - useful for so many calls its worth
fetching here */
state->domain_dn = talloc_reference(state,
- samdb_search_string(state->sam_ctx, mem_ctx, NULL,
+ samdb_search_string(state->sam_ldb, mem_ctx, NULL,
"dn", "(&(objectClass=domain)(!(objectclass=builtinDomain)))"));
if (!state->domain_dn) {
return NT_STATUS_NO_SUCH_DOMAIN;
@@ -251,7 +251,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
/* work out the builtin_dn - useful for so many calls its worth
fetching here */
state->builtin_dn = talloc_reference(state,
- samdb_search_string(state->sam_ctx, mem_ctx, NULL,
+ samdb_search_string(state->sam_ldb, mem_ctx, NULL,
"dn", "objectClass=builtinDomain"));
if (!state->builtin_dn) {
return NT_STATUS_NO_SUCH_DOMAIN;
@@ -260,13 +260,13 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
/* work out the system_dn - useful for so many calls its worth
fetching here */
state->system_dn = talloc_reference(state,
- samdb_search_string(state->sam_ctx, mem_ctx, state->domain_dn,
+ samdb_search_string(state->sam_ldb, mem_ctx, state->domain_dn,
"dn", "(&(objectClass=container)(cn=System))"));
if (!state->system_dn) {
return NT_STATUS_NO_SUCH_DOMAIN;
}
- sid_str = samdb_search_string(state->sam_ctx, mem_ctx, NULL,
+ sid_str = samdb_search_string(state->sam_ldb, mem_ctx, NULL,
"objectSid", "dn=%s", state->domain_dn);
if (!sid_str) {
return NT_STATUS_NO_SUCH_DOMAIN;
@@ -283,7 +283,7 @@ static NTSTATUS lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
}
state->domain_name = talloc_reference(state,
- samdb_search_string(state->sam_ctx, mem_ctx, NULL,
+ samdb_search_string(state->sam_ldb, mem_ctx, NULL,
"name", "dn=%s", state->domain_dn));
if (!state->domain_name) {
return NT_STATUS_NO_SUCH_DOMAIN;
@@ -359,7 +359,7 @@ static NTSTATUS lsa_info_AccountDomain(struct lsa_policy_state *state, TALLOC_CT
int ret;
struct ldb_message **res;
- ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs,
"dn=%s", state->domain_dn);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -381,7 +381,7 @@ static NTSTATUS lsa_info_DNS(struct lsa_policy_state *state, TALLOC_CTX *mem_ctx
int ret;
struct ldb_message **res;
- ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs,
"dn=%s", state->domain_dn);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -496,7 +496,7 @@ static NTSTATUS lsa_EnumAccounts(struct dcesrv_call_state *dce_call, TALLOC_CTX
state = h->data;
- ret = samdb_search(state->sam_ctx, mem_ctx, state->builtin_dn, &res, attrs,
+ ret = samdb_search(state->sam_ldb, mem_ctx, state->builtin_dn, &res, attrs,
"privilege=*");
if (ret <= 0) {
return NT_STATUS_NO_SUCH_USER;
@@ -600,7 +600,7 @@ static NTSTATUS lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALL
}
/* search for the trusted_domain record */
- ret = samdb_search(trusted_domain_state->policy->sam_ctx,
+ ret = samdb_search(trusted_domain_state->policy->sam_ldb,
mem_ctx, policy_state->system_dn, &msgs, attrs,
"(&(cn=%s)(objectclass=trustedDomain))",
r->in.info->name.string);
@@ -619,8 +619,8 @@ static NTSTATUS lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALL
return NT_STATUS_NO_MEMORY;
}
- samdb_msg_add_string(trusted_domain_state->policy->sam_ctx, mem_ctx, msg, "cn", name);
- samdb_msg_add_string(trusted_domain_state->policy->sam_ctx, mem_ctx, msg, "flatname", name);
+ samdb_msg_add_string(trusted_domain_state->policy->sam_ldb, mem_ctx, msg, "cn", name);
+ samdb_msg_add_string(trusted_domain_state->policy->sam_ldb, mem_ctx, msg, "flatname", name);
if (r->in.info->sid) {
const char *sid_string = dom_sid_string(mem_ctx, r->in.info->sid);
@@ -628,23 +628,23 @@ static NTSTATUS lsa_CreateTrustedDomain(struct dcesrv_call_state *dce_call, TALL
return NT_STATUS_NO_MEMORY;
}
- samdb_msg_add_string(trusted_domain_state->policy->sam_ctx, mem_ctx, msg, "securityIdentifier", sid_string);
+ samdb_msg_add_string(trusted_domain_state->policy->sam_ldb, mem_ctx, msg, "securityIdentifier", sid_string);
}
/* pull in all the template attributes. Note this is always from the global samdb */
- ret = samdb_copy_template(trusted_domain_state->policy->sam_ctx, mem_ctx, msg,
+ ret = samdb_copy_template(trusted_domain_state->policy->sam_ldb, mem_ctx, msg,
"(&(name=TemplateTrustedDomain)(objectclass=trustedDomainTemplate))");
if (ret != 0) {
DEBUG(0,("Failed to load TemplateTrustedDomain from samdb\n"));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- samdb_msg_add_string(trusted_domain_state->policy->sam_ctx, mem_ctx, msg, "objectClass", "trustedDomain");
+ samdb_msg_add_string(trusted_domain_state->policy->sam_ldb, mem_ctx, msg, "objectClass", "trustedDomain");
trusted_domain_state->trusted_domain_dn = talloc_reference(trusted_domain_state, msg->dn);
/* create the trusted_domain */
- ret = samdb_add(trusted_domain_state->policy->sam_ctx, mem_ctx, msg);
+ ret = samdb_add(trusted_domain_state->policy->sam_ldb, mem_ctx, msg);
if (ret != 0) {
DEBUG(0,("Failed to create trusted_domain record %s\n", msg->dn));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -700,7 +700,7 @@ static NTSTATUS lsa_OpenTrustedDomain(struct dcesrv_call_state *dce_call, TALLOC
}
/* search for the trusted_domain record */
- ret = samdb_search(trusted_domain_state->policy->sam_ctx,
+ ret = samdb_search(trusted_domain_state->policy->sam_ldb,
mem_ctx, policy_state->system_dn, &msgs, attrs,
"(&(securityIdentifier=%s)(objectclass=trustedDomain))",
sid_string);
@@ -765,7 +765,7 @@ static NTSTATUS lsa_OpenTrustedDomainByName(struct dcesrv_call_state *dce_call,
trusted_domain_state->policy = policy_state;
/* search for the trusted_domain record */
- ret = samdb_search(trusted_domain_state->policy->sam_ctx,
+ ret = samdb_search(trusted_domain_state->policy->sam_ldb,
mem_ctx, policy_state->system_dn, &msgs, attrs,
"(&(flatname=%s)(objectclass=trustedDomain))",
r->in.name.string);
@@ -850,7 +850,7 @@ static NTSTATUS lsa_QueryTrustedDomainInfo(struct dcesrv_call_state *dce_call, T
trusted_domain_state = h->data;
/* pull all the user attributes */
- ret = samdb_search(trusted_domain_state->policy->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(trusted_domain_state->policy->sam_ldb, mem_ctx, NULL, &res, attrs,
"dn=%s", trusted_domain_state->trusted_domain_dn);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -970,7 +970,7 @@ static NTSTATUS lsa_EnumTrustDom(struct dcesrv_call_state *dce_call, TALLOC_CTX
/* search for all users in this domain. This could possibly be cached and
resumed based on resume_key */
- count = samdb_search(policy_state->sam_ctx, mem_ctx, policy_state->system_dn, &domains, attrs,
+ count = samdb_search(policy_state->sam_ldb, mem_ctx, policy_state->system_dn, &domains, attrs,
"objectclass=trustedDomain");
if (count == -1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -1105,7 +1105,7 @@ static NTSTATUS lsa_lookup_sid(struct lsa_policy_state *state, TALLOC_CTX *mem_c
const char * const attrs[] = { "sAMAccountName", "sAMAccountType", "name", NULL};
NTSTATUS status;
- ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs,
"objectSid=%s", sid_str);
if (ret == 1) {
*name = ldb_msg_find_string(res[0], "sAMAccountName", NULL);
@@ -1324,7 +1324,7 @@ static NTSTATUS lsa_OpenAccount(struct dcesrv_call_state *dce_call, TALLOC_CTX *
}
/* check it really exists */
- astate->account_dn = samdb_search_string(state->sam_ctx, astate,
+ astate->account_dn = samdb_search_string(state->sam_ldb, astate,
NULL, "dn",
"(&(objectSid=%s)(objectClass=group))",
astate->account_sid_str);
@@ -1373,7 +1373,7 @@ static NTSTATUS lsa_EnumPrivsAccount(struct dcesrv_call_state *dce_call,
r->out.privs->unknown = 0;
r->out.privs->set = NULL;
- ret = samdb_search(astate->policy->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(astate->policy->sam_ldb, mem_ctx, NULL, &res, attrs,
"dn=%s", astate->account_dn);
if (ret != 1) {
return NT_STATUS_OK;
@@ -1429,7 +1429,7 @@ static NTSTATUS lsa_EnumAccountRights(struct dcesrv_call_state *dce_call,
return NT_STATUS_NO_MEMORY;
}
- ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs,
"objectSid=%s", sidstr);
if (ret != 1) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
@@ -1483,7 +1483,7 @@ static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call,
return NT_STATUS_NO_MEMORY;
}
- dn = samdb_search_string(state->sam_ctx, mem_ctx, NULL, "dn",
+ dn = samdb_search_string(state->sam_ldb, mem_ctx, NULL, "dn",
"objectSid=%s", sidstr);
if (dn == NULL) {
return NT_STATUS_NO_SUCH_USER;
@@ -1494,7 +1494,7 @@ static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call,
return NT_STATUS_NO_MEMORY;
}
- if (ldb_msg_add_empty(state->sam_ctx->ldb, msg, "privilege", ldb_flag)) {
+ if (ldb_msg_add_empty(state->sam_ldb, msg, "privilege", ldb_flag)) {
return NT_STATUS_NO_MEMORY;
}
@@ -1545,7 +1545,7 @@ static NTSTATUS lsa_AddRemoveAccountRights(struct dcesrv_call_state *dce_call,
return NT_STATUS_OK;
}
- ret = samdb_modify(state->sam_ctx, mem_ctx, msg);
+ ret = samdb_modify(state->sam_ldb, mem_ctx, msg);
if (ret != 0) {
if (ldb_flag == LDB_FLAG_MOD_DELETE) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
@@ -1737,7 +1737,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
if (strncmp("G$", r->in.name.string, 2) == 0) {
const char *name2;
name = &r->in.name.string[2];
- secret_state->sam_ctx = talloc_reference(secret_state, policy_state->sam_ctx);
+ secret_state->sam_ldb = talloc_reference(secret_state, policy_state->sam_ldb);
secret_state->global = True;
if (strlen(name) < 1) {
@@ -1746,7 +1746,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
name2 = talloc_asprintf(mem_ctx, "%s Secret", name);
/* search for the secret record */
- ret = samdb_search(secret_state->sam_ctx,
+ ret = samdb_search(secret_state->sam_ldb,
mem_ctx, policy_state->system_dn, &msgs, attrs,
"(&(cn=%s)(objectclass=secret))",
name2);
@@ -1764,7 +1764,7 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
return NT_STATUS_NO_MEMORY;
}
- samdb_msg_add_string(secret_state->sam_ctx, mem_ctx, msg, "cn", name2);
+ samdb_msg_add_string(secret_state->sam_ldb, mem_ctx, msg, "cn", name2);
} else {
secret_state->global = False;
@@ -1774,9 +1774,9 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
return NT_STATUS_INVALID_PARAMETER;
}
- secret_state->sam_ctx = talloc_reference(secret_state, secrets_db_connect(mem_ctx));
+ secret_state->sam_ldb = talloc_reference(secret_state, secrets_db_connect(mem_ctx));
/* search for the secret record */
- ret = samdb_search(secret_state->sam_ctx,
+ ret = samdb_search(secret_state->sam_ldb,
mem_ctx, "cn=LSA Secrets", &msgs, attrs,
"(&(cn=%s)(objectclass=secret))",
name);
@@ -1790,23 +1790,23 @@ static NTSTATUS lsa_CreateSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX
}
msg->dn = talloc_asprintf(mem_ctx, "cn=%s,cn=LSA Secrets", name);
- samdb_msg_add_string(secret_state->sam_ctx, mem_ctx, msg, "cn", name);
+ samdb_msg_add_string(secret_state->sam_ldb, mem_ctx, msg, "cn", name);
}
/* pull in all the template attributes. Note this is always from the global samdb */
- ret = samdb_copy_template(secret_state->policy->sam_ctx, mem_ctx, msg,
+ ret = samdb_copy_template(secret_state->policy->sam_ldb, mem_ctx, msg,
"(&(name=TemplateSecret)(objectclass=secretTemplate))");
if (ret != 0) {
DEBUG(0,("Failed to load TemplateSecret from samdb\n"));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
- samdb_msg_add_string(secret_state->sam_ctx, mem_ctx, msg, "objectClass", "secret");
+ samdb_msg_add_string(secret_state->sam_ldb, mem_ctx, msg, "objectClass", "secret");
secret_state->secret_dn = talloc_reference(secret_state, msg->dn);
/* create the secret */
- ret = samdb_add(secret_state->sam_ctx, mem_ctx, msg);
+ ret = samdb_add(secret_state->sam_ldb, mem_ctx, msg);
if (ret != 0) {
DEBUG(0,("Failed to create secret record %s\n", msg->dn));
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -1864,7 +1864,7 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
if (strncmp("G$", r->in.name.string, 2) == 0) {
name = &r->in.name.string[2];
- secret_state->sam_ctx = talloc_reference(secret_state, policy_state->sam_ctx);
+ secret_state->sam_ldb = talloc_reference(secret_state, policy_state->sam_ldb);
secret_state->global = True;
if (strlen(name) < 1) {
@@ -1872,7 +1872,7 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
}
/* search for the secret record */
- ret = samdb_search(secret_state->sam_ctx,
+ ret = samdb_search(secret_state->sam_ldb,
mem_ctx, policy_state->system_dn, &msgs, attrs,
"(&(cn=%s Secret)(objectclass=secret))",
name);
@@ -1886,7 +1886,7 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
}
} else {
- secret_state->sam_ctx = talloc_reference(secret_state, secrets_db_connect(mem_ctx));
+ secret_state->sam_ldb = talloc_reference(secret_state, secrets_db_connect(mem_ctx));
secret_state->global = False;
name = r->in.name.string;
@@ -1895,7 +1895,7 @@ static NTSTATUS lsa_OpenSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *m
}
/* search for the secret record */
- ret = samdb_search(secret_state->sam_ctx,
+ ret = samdb_search(secret_state->sam_ldb,
mem_ctx, "cn=LSA Secrets", &msgs, attrs,
"(&(cn=%s)(objectclass=secret))",
name);
@@ -1978,13 +1978,13 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
val.length = secret.length;
/* set value */
- if (samdb_msg_add_value(secret_state->sam_ctx,
+ if (samdb_msg_add_value(secret_state->sam_ldb,
mem_ctx, msg, "priorSecret", &val) != 0) {
return NT_STATUS_NO_MEMORY;
}
/* set old value mtime */
- if (samdb_msg_add_uint64(secret_state->sam_ctx,
+ if (samdb_msg_add_uint64(secret_state->sam_ldb,
mem_ctx, msg, "priorSetTime", nt_now) != 0) {
return NT_STATUS_NO_MEMORY;
}
@@ -1993,16 +1993,16 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
/* This behaviour varies depending of if this is a local, or a global secret... */
if (secret_state->global) {
/* set old value mtime */
- if (samdb_msg_add_uint64(secret_state->sam_ctx,
+ if (samdb_msg_add_uint64(secret_state->sam_ldb,
mem_ctx, msg, "lastSetTime", nt_now) != 0) {
return NT_STATUS_NO_MEMORY;
}
} else {
- if (samdb_msg_add_delete(secret_state->sam_ctx,
+ if (samdb_msg_add_delete(secret_state->sam_ldb,
mem_ctx, msg, "secret")) {
return NT_STATUS_NO_MEMORY;
}
- if (samdb_msg_add_delete(secret_state->sam_ctx,
+ if (samdb_msg_add_delete(secret_state->sam_ldb,
mem_ctx, msg, "lastSetTime")) {
return NT_STATUS_NO_MEMORY;
}
@@ -2024,13 +2024,13 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
val.length = secret.length;
/* set value */
- if (samdb_msg_add_value(secret_state->sam_ctx,
+ if (samdb_msg_add_value(secret_state->sam_ldb,
mem_ctx, msg, "secret", &val) != 0) {
return NT_STATUS_NO_MEMORY;
}
/* set new value mtime */
- if (samdb_msg_add_uint64(secret_state->sam_ctx,
+ if (samdb_msg_add_uint64(secret_state->sam_ldb,
mem_ctx, msg, "lastSetTime", nt_now) != 0) {
return NT_STATUS_NO_MEMORY;
}
@@ -2048,7 +2048,7 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
};
/* search for the secret record */
- ret = samdb_search(secret_state->sam_ctx,
+ ret = samdb_search(secret_state->sam_ldb,
mem_ctx, NULL, &res, attrs,
"(dn=%s)", secret_state->secret_dn);
if (ret == 0) {
@@ -2065,7 +2065,7 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
if (new_val) {
/* set value */
- if (samdb_msg_add_value(secret_state->sam_ctx,
+ if (samdb_msg_add_value(secret_state->sam_ldb,
mem_ctx, msg, "priorSecret",
new_val) != 0) {
return NT_STATUS_NO_MEMORY;
@@ -2074,7 +2074,7 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
/* set new value mtime */
if (ldb_msg_find_ldb_val(res[0], "lastSetTime")) {
- if (samdb_msg_add_uint64(secret_state->sam_ctx,
+ if (samdb_msg_add_uint64(secret_state->sam_ldb,
mem_ctx, msg, "priorSetTime", last_set_time) != 0) {
return NT_STATUS_NO_MEMORY;
}
@@ -2083,7 +2083,7 @@ static NTSTATUS lsa_SetSecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *me
}
/* modify the samdb record */
- ret = samdb_replace(secret_state->sam_ctx, mem_ctx, msg);
+ ret = samdb_replace(secret_state->sam_ldb, mem_ctx, msg);
if (ret != 0) {
/* we really need samdb.c to return NTSTATUS */
return NT_STATUS_UNSUCCESSFUL;
@@ -2121,7 +2121,7 @@ static NTSTATUS lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLOC_CTX *
secret_state = h->data;
/* pull all the user attributes */
- ret = samdb_search(secret_state->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(secret_state->sam_ldb, mem_ctx, NULL, &res, attrs,
"dn=%s", secret_state->secret_dn);
if (ret != 1) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -2340,7 +2340,7 @@ static NTSTATUS lsa_EnumAccountsWithUserRight(struct dcesrv_call_state *dce_call
return NT_STATUS_NO_SUCH_PRIVILEGE;
}
- ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs,
+ ret = samdb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs,
"privilege=%s", privname);
if (ret <= 0) {
return NT_STATUS_NO_SUCH_USER;
@@ -2541,7 +2541,7 @@ static NTSTATUS lsa_lookup_name(struct lsa_policy_state *state, TALLOC_CTX *mem_
name = p + 1;
}
- ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", name);
+ ret = samdb_search(state->sam_ldb, mem_ctx, NULL, &res, attrs, "sAMAccountName=%s", name);
if (ret == 1) {
const char *sid_str = ldb_msg_find_string(res[0], "objectSid", NULL);
if (sid_str == NULL) {
diff --git a/source4/rpc_server/netlogon/schannel_state.c b/source4/rpc_server/netlogon/schannel_state.c
index 8f5f80e256..e7c9c13314 100644
--- a/source4/rpc_server/netlogon/schannel_state.c
+++ b/source4/rpc_server/netlogon/schannel_state.c
@@ -32,10 +32,10 @@
/*
connect to the schannel ldb
*/
-static struct ldb_wrap *schannel_db_connect(TALLOC_CTX *mem_ctx)
+static struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx)
{
char *path;
- struct ldb_wrap *ldb;
+ struct ldb_context *ldb;
path = smbd_tmp_path(mem_ctx, "schannel.ldb");
if (!path) {
@@ -58,7 +58,7 @@ static struct ldb_wrap *schannel_db_connect(TALLOC_CTX *mem_ctx)
NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
struct creds_CredentialState *creds)
{
- struct ldb_wrap *ldb;
+ struct ldb_context *ldb;
struct ldb_message *msg;
struct ldb_val val, seed;
char *s;
@@ -112,23 +112,23 @@ NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
seed.data = creds->seed.data;
seed.length = sizeof(creds->seed.data);
- ldb_msg_add_value(ldb->ldb, msg, "sessionKey", &val);
- ldb_msg_add_value(ldb->ldb, msg, "seed", &seed);
- ldb_msg_add_string(ldb->ldb, msg, "expiry", s);
- ldb_msg_add_string(ldb->ldb, msg, "negotiateFlags", f);
- ldb_msg_add_string(ldb->ldb, msg, "secureChannelType", sct);
- ldb_msg_add_string(ldb->ldb, msg, "accountName", creds->account_name);
- ldb_msg_add_string(ldb->ldb, msg, "computerName", creds->computer_name);
+ ldb_msg_add_value(ldb, msg, "sessionKey", &val);
+ ldb_msg_add_value(ldb, msg, "seed", &seed);
+ ldb_msg_add_string(ldb, msg, "expiry", s);
+ ldb_msg_add_string(ldb, msg, "negotiateFlags", f);
+ ldb_msg_add_string(ldb, msg, "secureChannelType", sct);
+ ldb_msg_add_string(ldb, msg, "accountName", creds->account_name);
+ ldb_msg_add_string(ldb, msg, "computerName", creds->computer_name);
- ldb_delete(ldb->ldb, msg->dn);
+ ldb_delete(ldb, msg->dn);
- ret = ldb_add(ldb->ldb, msg);
+ ret = ldb_add(ldb, msg);
talloc_free(s);
if (ret != 0) {
DEBUG(0,("Unable to add %s to session key db - %s\n",
- msg->dn, ldb_errstring(ldb->ldb)));
+ msg->dn, ldb_errstring(ldb)));
talloc_free(ldb);
talloc_free(msg);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
@@ -148,7 +148,7 @@ NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
const char *computer_name,
struct creds_CredentialState **creds)
{
- struct ldb_wrap *ldb;
+ struct ldb_context *ldb;
time_t expiry;
struct ldb_message **res;
int ret;
@@ -171,7 +171,7 @@ NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- ret = ldb_search(ldb->ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res);
+ ret = ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res);
if (ret != 1) {
talloc_free(ldb);
return NT_STATUS_INVALID_HANDLE;