summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-06-08 23:22:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:08:59 -0500
commite5a00c8ca6cfbc6665d00aa7f13ca91aaf35da7a (patch)
tree541bef2f15043a303a11fa77776bbf0522bce8d2 /source4/dsdb/samdb/ldb_modules
parente3a6c6be79326578a1e9c7cb8547234eab62235f (diff)
downloadsamba-e5a00c8ca6cfbc6665d00aa7f13ca91aaf35da7a.tar.gz
samba-e5a00c8ca6cfbc6665d00aa7f13ca91aaf35da7a.tar.bz2
samba-e5a00c8ca6cfbc6665d00aa7f13ca91aaf35da7a.zip
r16108: Fixes from working with the partition module.
We were not using the correct baseDN for the templates search. Using NULL is no longer valid (like against AD). While chasing that down, return proper error codes, and use the ldb_set_errstr() to get a good error string back up to the UI layer. Andrew Bartlett (This used to be commit b31003403d84def6f11b21df566ff57c01da21b8)
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules')
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index e822bba842..2dd3c8d833 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -483,12 +483,14 @@ static int samldb_copy_template(struct ldb_module *module, struct ldb_message *m
struct ldb_message *t;
int ret, i, j;
+ struct ldb_dn *basedn = ldb_dn_string_compose(msg, samdb_base_dn(msg), "cn=Templates");
/* pull the template record */
- ret = ldb_search(module->ldb, NULL, LDB_SCOPE_SUBTREE, filter, NULL, &res);
+ ret = ldb_search(module->ldb, basedn, LDB_SCOPE_SUBTREE, filter, NULL, &res);
if (ret != LDB_SUCCESS || res->count != 1) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "samldb: ERROR: template '%s' matched too many records\n", filter);
- return -1;
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "samldb_copy_template: ERROR: template '%s' matched %d records, expected 1\n", filter,
+ res->count));
+ return LDB_ERR_OPERATIONS_ERROR;
}
t = res->msgs[0];
@@ -515,16 +517,16 @@ static int samldb_copy_template(struct ldb_module *module, struct ldb_message *m
if ( ! samldb_find_or_add_value(module, msg, el->name,
(char *)el->values[j].data,
(char *)el->values[j].data)) {
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Attribute adding failed...\n");
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Adding objectClass %s failed.\n", el->values[j].data));
talloc_free(res);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
} else {
if ( ! samldb_find_or_add_attribute(module, msg, el->name,
(char *)el->values[j].data)) {
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "Attribute adding failed...\n");
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Adding attribute %s failed.\n", el->name));
talloc_free(res);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
}
}
@@ -532,7 +534,7 @@ static int samldb_copy_template(struct ldb_module *module, struct ldb_message *m
talloc_free(res);
- return 0;
+ return LDB_SUCCESS;
}
static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_message *msg,
@@ -557,7 +559,6 @@ static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_
ret = samldb_copy_template(module, msg2, "(&(CN=TemplateGroup)(objectclass=groupTemplate))");
if (ret != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "samldb_fill_group_object: Error copying template!\n");
talloc_free(mem_ctx);
return ret;
}
@@ -755,13 +756,17 @@ static int samldb_fill_foreignSecurityPrincipal_object(struct ldb_module *module
ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
if (ret >= 1) {
const char *name = samdb_result_string(dom_msgs[0], "name", NULL);
- ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "Attempt to add foreign SID record with SID %s rejected, because this domian (%s) is already in the database", dom_sid_string(mem_ctx, sid), name));
+ ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx,
+ "Attempt to add foreign SID record with SID %s rejected, because this domian (%s) is already in the database",
+ dom_sid_string(mem_ctx, sid), name));
/* We don't really like the idea of foreign sids that are not foreign */
return LDB_ERR_CONSTRAINT_VIOLATION;
} else if (ret == -1) {
- ldb_debug(module->ldb, LDB_DEBUG_FATAL, "samldb_fill_foreignSecurityPrincipal_object: error searching for a domain with this sid: %s\n", dom_sid_string(mem_ctx, dom_sid));
+ ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx,
+ "samldb_fill_foreignSecurityPrincipal_object: error searching for a domain with this sid: %s\n",
+ dom_sid_string(mem_ctx, dom_sid)));
talloc_free(dom_msgs);
- return -1;
+ return LDB_ERR_OPERATIONS_ERROR;
}
/* This isn't an operation on a domain we know about, so just