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

jfthomps 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 05899194454af1296d2b62daf55aed89f1ffb740
Author: Josh Thompson <[email protected]>
AuthorDate: Tue May 21 13:39:15 2019 -0400

    VCL-1116 - use database hostnames for ad joined computers
    
    generally, changed usedbhostname to usedbhostnames and 
useDatabaseHostnamesForComputerObjects to usedbhostnames
    
    DataStructure.pm: changed $SUBROUTINE_MAPPINGS{image_domain_usedbhostname} 
to $SUBROUTINE_MAPPINGS{image_domain_usedbhostnames}
    
    Windows.pm: modified set_computer_hostname: changed 
get_image_domain_usedbhostname to get_image_domain_usedbhostnames
    
    update-vcl.sql modified addomain: added usedbhostnames
    
    vcl.sql: modified addomain: changed usedbhostname to usedbhostnames
    
    addomain.php
    -modified AJsaveResource: changed usedbhostname to usedbhostnames and 
useDatabaseHostnamesForComputerObjects to usedbhostnames
    -modified addResource: changed useDatabaseHostnamesForComputerObjects to 
usedbhostnames
    -modified validateResourceData: changed 
useDatabaseHostnamesForComputerObjects to usedbhostnames; set 
$return['usedbhostnames'] by calling processInputVar instead of referencing 
$_POST directly; added validation of $return['usedbhostnames']
    
    utils.php: modified getADdomains: changed 
useDatabaseHostnamesForComputerObjects to usedbhostnames
    
    addomain.js: modified inlineEditResourceCB and saveResource: changed 
useDatabaseHostnamesForComputerObjects to usedbhostnames
---
 managementnode/lib/VCL/DataStructure.pm     |  2 +-
 managementnode/lib/VCL/Module/OS/Windows.pm |  2 +-
 mysql/update-vcl.sql                        |  1 +
 mysql/vcl.sql                               |  2 +-
 web/.ht-inc/addomain.php                    | 15 +++++++++------
 web/.ht-inc/utils.php                       |  4 ++--
 web/js/resources/addomain.js                | 10 +++++-----
 7 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/managementnode/lib/VCL/DataStructure.pm 
b/managementnode/lib/VCL/DataStructure.pm
index ba8d614..1b0bf41 100644
--- a/managementnode/lib/VCL/DataStructure.pm
+++ b/managementnode/lib/VCL/DataStructure.pm
@@ -404,7 +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_usedbhostname} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{usedbhostname}';
+$SUBROUTINE_MAPPINGS{image_domain_usedbhostnames} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{usedbhostnames}';
 $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 027e333..a17c35c 100644
--- a/managementnode/lib/VCL/Module/OS/Windows.pm
+++ b/managementnode/lib/VCL/Module/OS/Windows.pm
@@ -12741,7 +12741,7 @@ sub set_computer_hostname {
                return;
        }
        
-       my $use_database_hostnames = 
$self->data->get_image_domain_usedbhostname();
+       my $use_database_hostnames = 
$self->data->get_image_domain_usedbhostnames();
        my $database_computer_hostname = $self->data->get_computer_hostname();
        my $system32_path = $self->get_system32_path() || return;
        
diff --git a/mysql/update-vcl.sql b/mysql/update-vcl.sql
index 624f3f1..60ddc8f 100644
--- a/mysql/update-vcl.sql
+++ b/mysql/update-vcl.sql
@@ -878,6 +878,7 @@ CREATE TABLE IF NOT EXISTS `addomain` (
   `username` varchar(64) NOT NULL default '',
   `password` varchar(256) NOT NULL default '',
   `secretid` smallint(5) unsigned NOT NULL,
+  `usedbhostnames` tinyint(1) unsigned NOT NULL default '0',
   PRIMARY KEY (`id`),
   KEY `domainDNSName` (`domainDNSName`),
   KEY `secretid` (`secretid`)
diff --git a/mysql/vcl.sql b/mysql/vcl.sql
index dea4ea9..45db9ea 100644
--- a/mysql/vcl.sql
+++ b/mysql/vcl.sql
@@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS `addomain` (
   `username` varchar(64) NOT NULL default '',
   `password` varchar(256) NOT NULL default '',
   `secretid` smallint(5) unsigned NOT NULL,
-  `usedbhostname` tinyint(1) unsigned NOT NULL default '0',
+  `usedbhostnames` tinyint(1) unsigned NOT NULL default '0',
   PRIMARY KEY (`id`),
   KEY `domainDNSName` (`domainDNSName`),
   KEY `secretid` (`secretid`)
diff --git a/web/.ht-inc/addomain.php b/web/.ht-inc/addomain.php
index e59d72c..7e9f5a1 100644
--- a/web/.ht-inc/addomain.php
+++ b/web/.ht-inc/addomain.php
@@ -242,9 +242,9 @@ class ADdomain extends Resource {
                        # dnsservers
                        if($data['dnsservers'] != $olddata['dnsservers'])
                                $updates[] = "dnsServers = 
'{$data['dnsservers']}'";
-                       # useDatabaseHostnamesForComputerObjects
-                       if($data['useDatabaseHostnamesForComputerObjects'] != 
$olddata['useDatabaseHostnamesForComputerObjects'])
-                           $updates[] = "usedbhostname = 
{$data['useDatabaseHostnamesForComputerObjects']}";
+                       # usedbhostnames
+                       if($data['usedbhostnames'] != 
$olddata['usedbhostnames'])
+                           $updates[] = "usedbhostnames = 
{$data['usedbhostnames']}";
                        if(count($updates)) {
                                $query = "UPDATE addomain SET "
                                       . implode(', ', $updates)
@@ -350,7 +350,7 @@ class ADdomain extends Resource {
                                .       "password, "
                                .       "secretid, "
                                .       "dnsServers, "
-                               .       "usedbhostname) "
+                               .       "usedbhostnames) "
                                .       "VALUES ('{$data['name']}', "
                                .       "$ownerid, "
                                .       "'{$data['domaindnsname']}', "
@@ -358,7 +358,7 @@ class ADdomain extends Resource {
                                .       "'$encpass', "
                                .       "$secretid, "
                                .       "'{$data['dnsservers']}', "
-                               .       
"'{$data['useDatabaseHostnamesForComputerObjects']}')";
+                               .       "'{$data['usedbhostnames']}')";
                doQuery($query);
 
                $rscid = dbLastInsertID();
@@ -518,7 +518,7 @@ class ADdomain extends Resource {
                $return["password"] = $_POST['password'];
                $return["password2"] = $_POST['password2'];
                $return["dnsservers"] = processInputVar("dnsservers", 
ARG_STRING);
-               $return["useDatabaseHostnamesForComputerObjects"] = 
$_POST['useDatabaseHostnamesForComputerObjects'];
+               $return["usedbhostnames"] = processInputVar('usedbhostnames', 
ARG_NUMERIC, 0);
 
                if(! 
preg_match("/^([A-Za-z0-9-!@#$%^&\*\(\)_=\+\[\]{}\\\|:;,\.\/\?~` ]){2,30}$/", 
$return['name'])) {
                        $return['error'] = 1;
@@ -563,6 +563,9 @@ class ADdomain extends Resource {
                        }
                }
 
+               if($return['usedbhostnames'] != 0 && $return['usedbhostnames'] 
!= 1)
+                       $return['usedbhostnames'] = 0;
+
                if($return['error'])
                        $return['errormsg'] = implode('<br>', $errormsg);
 
diff --git a/web/.ht-inc/utils.php b/web/.ht-inc/utils.php
index 6dc4f5b..662ab77 100644
--- a/web/.ht-inc/utils.php
+++ b/web/.ht-inc/utils.php
@@ -9495,7 +9495,7 @@ function getNATports($resid) {
 /// \b username\n
 /// \b dnsservers\n
 /// \b secretid\n
-/// \b useDatabaseHostnamesForComputerObjects\n
+/// \b usedbhostnames
 ///
 /// \brief builds an array of AD domains
 ///
@@ -9510,7 +9510,7 @@ function getADdomains($addomainid=0) {
               .        "ad.username, "
               .        "ad.dnsServers AS dnsservers, "
               .        "ad.secretid, "
-              .        "ad.usedbhostname AS 
useDatabaseHostnamesForComputerObjects "
+              .        "ad.usedbhostnames "
               . "FROM addomain ad, "
               .      "affiliation a, "
               .      "user u, "
diff --git a/web/js/resources/addomain.js b/web/js/resources/addomain.js
index 158d97c..e782586 100644
--- a/web/js/resources/addomain.js
+++ b/web/js/resources/addomain.js
@@ -44,8 +44,8 @@ function inlineEditResourceCB(data, ioArgs) {
                dijit.byId('domaindnsname').set('value', 
data.items.data.domaindnsname);
                dijit.byId('username').set('value', data.items.data.username);
                dijit.byId('dnsservers').set('value', 
data.items.data.dnsservers);
-               if (data.items.data.useDatabaseHostnamesForComputerObjects == 
1) {
-                       dijit.byId('usedbhostnames').set('checked', 
data.items.data.useDatabaseHostnamesForComputerObjects)
+               if(data.items.data.usedbhostnames == 1) {
+                       dijit.byId('usedbhostnames').set('checked', 
data.items.data.usedbhostnames)
                }
                dijit.byId('password').set('value', '********');
                dijit.byId('password2').set('value', 'xxxxxxxx');
@@ -90,12 +90,12 @@ function saveResource() {
                dojo.byId('addeditdlgerrmsg').innerHTML = _('Passwords do not 
match');
                return;
        }
-       // update useDatabaseHostnamesForComputerObjects
+       // update usedbhostnames
        if(dijit.byId('usedbhostnames').get('checked')) {
-               data['useDatabaseHostnamesForComputerObjects'] = 1;
+               data['usedbhostnames'] = 1;
        }
        else {
-               data['useDatabaseHostnamesForComputerObjects'] = 0;
+               data['usedbhostnames'] = 0;
        }
        dijit.byId('addeditbtn').set('disabled', true);
        RPCwrapper(data, saveResourceCB, 1);

Reply via email to