summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2005-07-07 13:42:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:58:18 -0500
commitd303b0203b4b8a2e4146851c6ee03d1ee4c6a392 (patch)
tree1294d31da73a7d20957522d988e6e6eb6fb611a7 /source3
parente0ffbfc5587ed296d5a9e8f5ed30b6e8b2cd6fcf (diff)
downloadsamba-d303b0203b4b8a2e4146851c6ee03d1ee4c6a392.tar.gz
samba-d303b0203b4b8a2e4146851c6ee03d1ee4c6a392.tar.bz2
samba-d303b0203b4b8a2e4146851c6ee03d1ee4c6a392.zip
r8205: try to improve readability of smbldap_search_domain_info()
Guenther (This used to be commit ca9acd149a36ca36a9a4e2a35b97cae610b3b5ed)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/smbldap_util.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/source3/lib/smbldap_util.c b/source3/lib/smbldap_util.c
index 46ea5b7bfc..98abe7f0d7 100644
--- a/source3/lib/smbldap_util.c
+++ b/source3/lib/smbldap_util.c
@@ -155,7 +155,7 @@ NTSTATUS smbldap_search_domain_info(struct smbldap_state *ldap_state,
LDAPMessage ** result, const char *domain_name,
BOOL try_add)
{
- NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
pstring filter;
int rc;
const char **attr_list;
@@ -168,7 +168,6 @@ NTSTATUS smbldap_search_domain_info(struct smbldap_state *ldap_state,
DEBUG(2, ("Searching for:[%s]\n", filter));
-
attr_list = get_attr_list( dominfo_attr_list );
rc = smbldap_search_suffix(ldap_state, filter, attr_list , result);
free_attr_list( attr_list );
@@ -176,28 +175,44 @@ NTSTATUS smbldap_search_domain_info(struct smbldap_state *ldap_state,
if (rc != LDAP_SUCCESS) {
DEBUG(2,("Problem during LDAPsearch: %s\n", ldap_err2string (rc)));
DEBUG(2,("Query was: %s, %s\n", lp_ldap_suffix(), filter));
- } else if (ldap_count_entries(ldap_state->ldap_struct, *result) < 1) {
+ goto failed;
+ }
+
+ count = ldap_count_entries(ldap_state->ldap_struct, *result);
+
+ if (count == 1)
+ return NT_STATUS_OK;
+
+ ldap_msgfree(*result);
+ *result = NULL;
+
+ if (count < 1) {
+
DEBUG(3, ("Got no domain info entries for domain\n"));
- ldap_msgfree(*result);
- *result = NULL;
- if ( try_add && NT_STATUS_IS_OK(ret = add_new_domain_info(ldap_state, domain_name)) ) {
- return smbldap_search_domain_info(ldap_state, result, domain_name, False);
- }
- else {
+
+ if (!try_add)
+ goto failed;
+
+ status = add_new_domain_info(ldap_state, domain_name);
+ if (NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Adding domain info for %s failed with %s\n",
- domain_name, nt_errstr(ret)));
- return ret;
+ domain_name, nt_errstr(status)));
+ goto failed;
}
- } else if ((count = ldap_count_entries(ldap_state->ldap_struct, *result)) > 1) {
+
+ return smbldap_search_domain_info(ldap_state, result, domain_name, False);
+
+ }
+
+ if (count > 1 ) {
+
DEBUG(0, ("Got too many (%d) domain info entries for domain %s\n",
count, domain_name));
- ldap_msgfree(*result);
- *result = NULL;
- return ret;
- } else {
- return NT_STATUS_OK;
+ goto failed;
}
+
+failed:
+ return status;
- return ret;
}