This is an automated email from the ASF dual-hosted git repository.

junaid pushed a commit to branch 
VCL-1116_use_database_hostnames_for_ad_joined_computers
in repository https://gitbox.apache.org/repos/asf/vcl.git

commit 2ecb20f43858f89a048c08ffae21301176b21785
Author: Junaid Ali <jun...@apache.org>
AuthorDate: Thu Mar 14 15:35:55 2019 -0500

    added managementnode code to use database hostnames if configured in 
database
---
 managementnode/lib/VCL/DataStructure.pm     |  1 +
 managementnode/lib/VCL/Module/OS/Windows.pm | 22 +++++++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/managementnode/lib/VCL/DataStructure.pm 
b/managementnode/lib/VCL/DataStructure.pm
index 3d57fdf..0068546 100644
--- a/managementnode/lib/VCL/DataStructure.pm
+++ b/managementnode/lib/VCL/DataStructure.pm
@@ -404,6 +404,7 @@ $SUBROUTINE_MAPPINGS{image_domain_owner_id} = 
'$self->request_data->{reservation
 #$SUBROUTINE_MAPPINGS{image_domain_password} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{password}';
 # Explicit subroutine
 $SUBROUTINE_MAPPINGS{image_domain_secret_id} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{secretid}';
 $SUBROUTINE_MAPPINGS{image_domain_username} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{username}';
+$SUBROUTINE_MAPPINGS{image_domain_usedatabasehostnamesforcomputerobjects} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{usedatabasehostnamesforcomputerobjects}';
 $SUBROUTINE_MAPPINGS{image_domain_base_ou} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{imageaddomain}{baseOU}';
 $SUBROUTINE_MAPPINGS{image_domain_cryptsecret} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{cryptsecret}{cryptsecret}';
 
diff --git a/managementnode/lib/VCL/Module/OS/Windows.pm 
b/managementnode/lib/VCL/Module/OS/Windows.pm
index 479fc22..5451d4a 100644
--- a/managementnode/lib/VCL/Module/OS/Windows.pm
+++ b/managementnode/lib/VCL/Module/OS/Windows.pm
@@ -12731,6 +12731,7 @@ sub set_computer_hostname {
                return;
        }
        
+       my $use_database_hostnames = 
$self->data->image_domain_usedatabasehostnamesforcomputerobjects();
        my $database_computer_hostname = $self->data->get_computer_hostname();
        my $system32_path = $self->get_system32_path() || return;
        
@@ -12767,8 +12768,20 @@ sub set_computer_hostname {
                $dns_suffix = $2;
        }
        
-       # Disable 'Change primary DNS suffix when domain membership changes'
-       
$self->reg_add('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters',
 'SyncDomainWithMembership', 'REG_DWORD', 0);
+       if ($use_database_hostnames == 1) {
+               $new_computer_name = $database_computer_hostname;
+               notify($ERRORS{'DEBUG'}, 0, "active directory forces using 
database configured hostname: $new_computer_name");
+               # Enable 'Change primary DNS suffix when domain membership 
changes'
+               
$self->reg_add('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters',
 'SyncDomainWithMembership', 'REG_DWORD', 1);
+       }
+       else {
+               # Disable 'Change primary DNS suffix when domain membership 
changes'
+               
$self->reg_add('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters',
 'SyncDomainWithMembership', 'REG_DWORD', 0);
+               # Set the DNS suffix registry key
+               if ($dns_suffix) {
+                       
$self->reg_add('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters',
 'NV Domain', 'REG_SZ', $dns_suffix);
+               }
+       }
        
        # Assemble the command
        my $command = "echo | cmd.exe /c \"$system32_path/Wbem/wmic.exe 
COMPUTERSYSTEM WHERE Name=\\\"%COMPUTERNAME%\\\" Rename 
\\\"$new_computer_name\\\"\"";
@@ -12786,11 +12799,6 @@ sub set_computer_hostname {
                return 0;
        }
        
-       # Set the DNS suffix registry key
-       if ($dns_suffix) {
-               
$self->reg_add('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters',
 'NV Domain', 'REG_SZ', $dns_suffix);
-       }
-       
        return 1;
 }
 

Reply via email to