If name_to_fqdn fails, retry with the dns domain the DC gave us
authorVolker Lendecke <vl@samba.org>
Mon, 6 Oct 2008 21:10:23 +0000 (14:10 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 9 Dec 2008 10:22:15 +0000 (11:22 +0100)
This is a workaround for the cases where you want to join under a netbios name
that is different from your hostname, i.e. a name that can not be found in
/etc/hosts or dns. In these cases, name_to_fqdn fails or gives invalid results.
(cherry picked from commit 84951b54bc1473aa9275c02cc37a9f0d7d4150e2)
(cherry picked from commit 82a086fb6f70dd6b725e4976293bc377a6a90f3a)

source/libnet/libnet_join.c

index 86cbce02242f728bad51ea6495be9a391494dd2d..7451cb27c6f2e200126b1461087bea95c1b49a04 100644 (file)
@@ -357,10 +357,15 @@ static ADS_STATUS libnet_join_set_machine_spn(TALLOC_CTX *mem_ctx,
        strupper_m(spn);
        spn_array[0] = spn;
 
-       if (name_to_fqdn(my_fqdn, r->in.machine_name) &&
-           !strequal(my_fqdn, r->in.machine_name)) {
+       if (!name_to_fqdn(my_fqdn, r->in.machine_name)
+           || (strchr(my_fqdn, '.') == NULL)) {
+               fstr_sprintf(my_fqdn, "%s.%s", r->in.machine_name,
+                       r->out.dns_domain_name);
+       }
+
+       strlower_m(my_fqdn);
 
-               strlower_m(my_fqdn);
+       if (!strequal(my_fqdn, r->in.machine_name)) {
                spn = talloc_asprintf(mem_ctx, "HOST/%s", my_fqdn);
                if (!spn) {
                        return ADS_ERROR_LDAP(LDAP_NO_MEMORY);