From 6dfa851ce95b372c6c4bdd7a6c07c1ee183d1f7a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 7 May 2010 22:43:36 +1000 Subject: s4:dsdb Provide an intelegent fallback if not CN=Subnets is found We may as well fall back rather than return NULL (which callers don't do useful things with). Andrew Bartlett --- source4/dsdb/common/util.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/dsdb') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 7064fcf67d..40f0a7f6c6 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -1607,7 +1607,7 @@ const char *samdb_client_site_name(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const struct ldb_val *val; const char *site_name = NULL, *l_subnet_name = NULL; const char *allow_list[2] = { NULL, NULL }; - unsigned int i; + unsigned int i, count; int cnt, ret; /* @@ -1632,13 +1632,17 @@ const char *samdb_client_site_name(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, ret = ldb_search(ldb, mem_ctx, &res, subnets_dn, LDB_SCOPE_ONELEVEL, attrs, NULL); - if (ret != LDB_SUCCESS) { + if (ret == LDB_ERR_NO_SUCH_OBJECT) { + count = 0; + } else if (ret != LDB_SUCCESS) { talloc_free(sites_container_dn); talloc_free(subnets_dn); return NULL; + } else { + count = res->count; } - for (i = 0; i < res->count; i++) { + for (i = 0; i < count; i++) { l_subnet_name = ldb_msg_find_attr_as_string(res->msgs[i], "cn", NULL); -- cgit