summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-05-08 12:16:04 +0200
committerGünther Deschner <gd@samba.org>2008-05-09 14:59:19 +0200
commite668cb45941b4cbe7dbcb5bb2e4de3fb1d3784de (patch)
treee5f7fb4bf3331f4a80129672a2516ed675c12b94
parent4bd94c8338bef61477170bc41a8073739d55d812 (diff)
downloadsamba-e668cb45941b4cbe7dbcb5bb2e4de3fb1d3784de.tar.gz
samba-e668cb45941b4cbe7dbcb5bb2e4de3fb1d3784de.tar.bz2
samba-e668cb45941b4cbe7dbcb5bb2e4de3fb1d3784de.zip
dsgetdcname: add map_dc_and_domain_names() for consolidating returned names.
Guenther (This used to be commit eb7fee6e2a00326c03aa013058247e06279a4930)
-rw-r--r--source3/libsmb/dsgetdcname.c129
1 files changed, 79 insertions, 50 deletions
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 0db457a45a..2c8f42399f 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -812,6 +812,44 @@ static NTSTATUS make_domain_controller_info(TALLOC_CTX *mem_ctx,
/****************************************************************
****************************************************************/
+static void map_dc_and_domain_names(uint32_t flags,
+ const char *dc_name,
+ const char *domain_name,
+ const char *dns_dc_name,
+ const char *dns_domain_name,
+ uint32_t *dc_flags,
+ const char **hostname_p,
+ const char **domain_p)
+{
+ switch (flags & 0xf0000000) {
+ case DS_RETURN_FLAT_NAME:
+ if (dc_name && domain_name &&
+ *dc_name && *domain_name) {
+ *hostname_p = dc_name;
+ *domain_p = domain_name;
+ break;
+ }
+ case DS_RETURN_DNS_NAME:
+ default:
+ if (dns_dc_name && dns_domain_name &&
+ *dns_dc_name && *dns_domain_name) {
+ *hostname_p = dns_dc_name;
+ *domain_p = dns_domain_name;
+ *dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER;
+ break;
+ }
+ if (dc_name && domain_name &&
+ *dc_name && *domain_name) {
+ *hostname_p = dc_name;
+ *domain_p = domain_name;
+ break;
+ }
+ }
+}
+
+/****************************************************************
+****************************************************************/
+
static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
uint32_t flags,
struct sockaddr_storage *ss,
@@ -845,8 +883,15 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
dc_address_type = DS_ADDRESS_TYPE_NETBIOS;
}
- dc_hostname = r->logon1.pdc_name;
- dc_domain_name = r->logon1.domain_name;
+ map_dc_and_domain_names(flags,
+ r->logon1.pdc_name,
+ r->logon1.domain_name,
+ NULL,
+ NULL,
+ &dc_flags,
+ &dc_hostname,
+ &dc_domain_name);
+
if (flags & DS_PDC_REQUIRED) {
dc_flags = NBT_SERVER_WRITABLE | NBT_SERVER_PDC;
}
@@ -858,18 +903,14 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
dc_address_type = DS_ADDRESS_TYPE_INET;
}
- switch (flags & 0xf0000000) {
- case DS_RETURN_FLAT_NAME:
- dc_hostname = r->logon3.pdc_name;
- dc_domain_name = r->logon3.domain_name;
- break;
- case DS_RETURN_DNS_NAME:
- default:
- dc_hostname = r->logon3.pdc_dns_name;
- dc_domain_name = r->logon3.dns_domain;
- dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER;
- break;
- }
+ map_dc_and_domain_names(flags,
+ r->logon3.pdc_name,
+ r->logon3.domain_name,
+ r->logon3.pdc_dns_name,
+ r->logon3.dns_domain,
+ &dc_flags,
+ &dc_hostname,
+ &dc_domain_name);
dc_flags |= r->logon3.server_type;
dc_forest = r->logon3.forest;
@@ -885,18 +926,14 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
dc_address_type = DS_ADDRESS_TYPE_NETBIOS;
}
- switch (flags & 0xf0000000) {
- case DS_RETURN_FLAT_NAME:
- dc_hostname = r->logon5.pdc_name;
- dc_domain_name = r->logon5.domain;
- break;
- case DS_RETURN_DNS_NAME:
- default:
- dc_hostname = r->logon5.pdc_dns_name;
- dc_domain_name = r->logon5.dns_domain;
- dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER;
- break;
- }
+ map_dc_and_domain_names(flags,
+ r->logon5.pdc_name,
+ r->logon5.domain,
+ r->logon5.pdc_dns_name,
+ r->logon5.dns_domain,
+ &dc_flags,
+ &dc_hostname,
+ &dc_domain_name);
dc_flags |= r->logon5.server_type;
dc_forest = r->logon5.forest;
@@ -918,18 +955,14 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
dc_address_type = DS_ADDRESS_TYPE_INET;
}
- switch (flags & 0xf0000000) {
- case DS_RETURN_FLAT_NAME:
- dc_hostname = r->logon13.pdc_name;
- dc_domain_name = r->logon13.domain;
- break;
- case DS_RETURN_DNS_NAME:
- default:
- dc_hostname = r->logon13.pdc_dns_name;
- dc_domain_name = r->logon13.dns_domain;
- dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER;
- break;
- }
+ map_dc_and_domain_names(flags,
+ r->logon13.pdc_name,
+ r->logon13.domain,
+ r->logon13.pdc_dns_name,
+ r->logon13.dns_domain,
+ &dc_flags,
+ &dc_hostname,
+ &dc_domain_name);
dc_flags |= r->logon13.server_type;
dc_forest = r->logon13.forest;
@@ -944,18 +977,14 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
dc_address_type = DS_ADDRESS_TYPE_INET;
}
- switch (flags & 0xf0000000) {
- case DS_RETURN_FLAT_NAME:
- dc_hostname = r->logon29.pdc_name;
- dc_domain_name = r->logon29.domain;
- break;
- case DS_RETURN_DNS_NAME:
- default:
- dc_hostname = r->logon29.pdc_dns_name;
- dc_domain_name = r->logon29.dns_domain;
- dc_flags |= DS_DNS_DOMAIN | DS_DNS_CONTROLLER;
- break;
- }
+ map_dc_and_domain_names(flags,
+ r->logon29.pdc_name,
+ r->logon29.domain,
+ r->logon29.pdc_dns_name,
+ r->logon29.dns_domain,
+ &dc_flags,
+ &dc_hostname,
+ &dc_domain_name);
dc_flags |= r->logon29.server_type;
dc_forest = r->logon29.forest;