diff options
author | Simo Sorce <idra@samba.org> | 2005-02-27 11:35:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:10:55 -0500 |
commit | b1b14817eaa6e6579596d54166e17bc8d5605c01 (patch) | |
tree | b1af59838a0337dd52b510374b048255397dfe24 /source4/dsdb | |
parent | d2dc86994e7075490f95faa1cc85008feb38f04a (diff) | |
download | samba-b1b14817eaa6e6579596d54166e17bc8d5605c01.tar.gz samba-b1b14817eaa6e6579596d54166e17bc8d5605c01.tar.bz2 samba-b1b14817eaa6e6579596d54166e17bc8d5605c01.zip |
r5585: LDB interfaces change:
changes:
- ldb_wrap disappears from code and become a private structure of db_wrap.c
thanks to our move to talloc in ldb code, we do not need to expose it anymore
- removal of ldb_close() function form the code
thanks to our move to talloc in ldb code, we do not need it anymore
use talloc_free() to close and free an ldb database
- some minor updates to ldb modules code to cope with the change and fix some
bugs I found out during the process
(This used to be commit d58be9e74b786a11a57e89df36081d55730dfe0a)
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/samdb/samdb.c | 152 |
1 files changed, 76 insertions, 76 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); } /* |