int i;
struct lsa_DomainList dom_list;
fstring pdc_name;
+ bool found_domain;
/* trusting domains listing variables */
struct policy_handle domain_hnd;
* Keep calling LsaEnumTrustdom over opened pipe until
* the end of enumeration is reached
*/
-
+
d_printf(_("Trusted domains list:\n\n"));
+ found_domain = false;
+
do {
nt_status = rpccli_lsa_EnumTrustDom(pipe_hnd, mem_ctx,
&connect_hnd,
for (i = 0; i < dom_list.count; i++) {
print_trusted_domain(dom_list.domains[i].sid,
dom_list.domains[i].name.string);
+ found_domain = true;
};
- /*
- * in case of no trusted domains say something rather
- * than just display blank line
- */
- if (!dom_list.count) d_printf(_("none\n"));
} while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
+ /*
+ * in case of no trusted domains say something rather
+ * than just display blank line
+ */
+ if (!found_domain) {
+ d_printf(_("none\n"));
+ }
+
/* close this connection before doing next one */
nt_status = rpccli_lsa_Close(pipe_hnd, mem_ctx, &connect_hnd);
if (NT_STATUS_IS_ERR(nt_status)) {
* perform actual enumeration
*/
+ found_domain = false;
+
enum_ctx = 0; /* reset enumeration context from last enumeration */
do {
char *str = CONST_DISCARD(char *, trusts->entries[i].name.string);
+ found_domain = true;
+
/*
* get each single domain's sid (do we _really_ need this ?):
* 1) connect to domain's pdc
"responding: %s\n"),
nt_errstr(nt_status));
d_printf(_("couldn't get domain's sid\n"));
- };
- };
-
- if (!num_domains) d_printf("none\n");
+ }
+ }
} while (NT_STATUS_EQUAL(nt_status, STATUS_MORE_ENTRIES));
+ if (!found_domain) {
+ d_printf("none\n");
+ }
+
/* close opened samr and domain policy handles */
nt_status = rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_hnd);
if (!NT_STATUS_IS_OK(nt_status)) {