summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-01-14 11:47:49 +1100
committerAndrew Tridgell <tridge@samba.org>2011-01-14 16:39:33 +1100
commit3b7c49843734720fb31d4fa7d5d14ec0debb5867 (patch)
tree9f06a3cacb8edf51e62e057e29f9e39bfbbcee5f
parent15c81078682a9ff67ff8c2f5c25fb4fad3a68616 (diff)
downloadsamba-3b7c49843734720fb31d4fa7d5d14ec0debb5867.tar.gz
samba-3b7c49843734720fb31d4fa7d5d14ec0debb5867.tar.bz2
samba-3b7c49843734720fb31d4fa7d5d14ec0debb5867.zip
s4-dsdb: replaced another use of samdb_search in a ldb module
we should be using the dsdb_module_search*() calls Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index ff61583229..94648c6621 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -167,6 +167,8 @@ static int samldb_check_sAMAccountName(struct samldb_ctx *ac)
struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
const char *name;
int ret;
+ struct ldb_result *res;
+ const char *noattrs[] = { NULL };
if (ldb_msg_find_element(ac->msg, "sAMAccountName") == NULL) {
ret = samldb_generate_sAMAccountName(ldb, ac->msg);
@@ -183,17 +185,21 @@ static int samldb_check_sAMAccountName(struct samldb_ctx *ac)
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- ret = samdb_search_count(ldb, ac, NULL, "(sAMAccountName=%s)",
+ ret = dsdb_module_search(ac->module, ac, &res,
+ NULL, LDB_SCOPE_SUBTREE, noattrs,
+ DSDB_FLAG_NEXT_MODULE, "(sAMAccountName=%s)",
ldb_binary_encode_string(ac, name));
- if ((ret < 0) || (ret > 1)) {
- return ldb_operr(ldb);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
- if (ret == 1) {
+ if (res->count != 0) {
ldb_asprintf_errstring(ldb,
"samldb: Account name (sAMAccountName) '%s' already in use!",
name);
+ talloc_free(res);
return LDB_ERR_ENTRY_ALREADY_EXISTS;
}
+ talloc_free(res);
return samldb_next_step(ac);
}