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 a242e230fcd9e3f7d1fbf4b360219976add5ede8 Author: Junaid Ali <[email protected]> AuthorDate: Wed Mar 13 14:53:48 2019 -0500 updated database to hold configuration. updated front end code to add checkbox to ADDomain Edit page to save this setting to database --- mysql/vcl.sql | 1 + web/.ht-inc/addomain.php | 17 +++++++++++++---- web/.ht-inc/utils.php | 6 ++++-- web/js/resources/addomain.js | 15 +++++++++++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/mysql/vcl.sql b/mysql/vcl.sql index a5e41b1..00461ec 100644 --- a/mysql/vcl.sql +++ b/mysql/vcl.sql @@ -38,6 +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, + `useDatabaseHostnamesForComputerObjects` 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 a7259d5..997362c 100644 --- a/web/.ht-inc/addomain.php +++ b/web/.ht-inc/addomain.php @@ -242,6 +242,9 @@ class ADdomain extends Resource { # dnsservers if($data['dnsservers'] != $olddata['dnsservers']) $updates[] = "dnsServers = '{$data['dnsservers']}'"; + # useDatabaseHostnamesForComputerObjects + if($data['useDatabaseHostnamesForComputerObjects'] != $olddata['useDatabaseHostnamesForComputerObjects']) + $updates[] = "useDatabaseHostnamesForComputerObjects = {$data['useDatabaseHostnamesForComputerObjects']}"; if(count($updates)) { $query = "UPDATE addomain SET " . implode(', ', $updates) @@ -346,14 +349,16 @@ class ADdomain extends Resource { . "username, " . "password, " . "secretid, " - . "dnsServers) " + . "dnsServers, " + . "useDatabaseHostnamesForComputerObjects) " . "VALUES ('{$data['name']}', " . "$ownerid, " . "'{$data['domaindnsname']}', " . "'{$data['username']}', " . "'$encpass', " . "$secretid, " - . "'{$data['dnsservers']}')"; + . "'{$data['dnsservers']}', " + . "'{$data['useDatabaseHostnamesForComputerObjects']}')"; doQuery($query); $rscid = dbLastInsertID(); @@ -423,14 +428,16 @@ class ADdomain extends Resource { $errmsg = i("Password must be at least 4 characters long"); $h .= labeledFormItem('password', i('Password'), 'password', '^.{4,256}$', 1, '', $errmsg, '', '', '200px'); # confirm password - $h .= labeledFormItem('password2', i('Confirm Password'), 'password', '', 1, '', '', '', '', '200px'); + $h .= labeledFormItem('password2', i('Confirm Password'), 'password', '', 1, '', '', '', '', '200px'); + # use database hostname checkbox + $h .= labeledFormItem('usedbhostnames', i('Use Database Hostnames'), 'check', '', '', '', '', '', '', '', helpIcon('usedbhostnameshelp')); $h .= "<br>\n"; # dns server list $ipreg = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'; $reg = "^($ipreg,)*($ipreg)$"; $errmsg = i("Invalid IP address specified - must be a valid IPV4 address"); $h .= labeledFormItem('dnsservers', i('DNS Server(s)'), 'text', $reg, 0, '', $errmsg, - '', '', '300px', helpIcon('dnsservershelp')); + '', '', '300px', helpIcon('dnsservershelp')); $h .= "</div>\n"; # center $h .= "</div>\n"; # addomaindlgcontent @@ -473,6 +480,7 @@ class ADdomain extends Resource { $h .= helpTooltip('domaindnsnamehelp', i("domain name registered in DNS for Active Directory Domain (ex: ad.example.com)")); $h .= helpTooltip('usernamehelp', i("These credentials will be used to register reserved computers with AD.")); $h .= helpTooltip('dnsservershelp', i("comma delimited list of IP addresses for DNS servers that handle Domain DNS")); + $h .= helpTooltip('usedbhostnameshelp', i("Check this option if you like to have the computer object names within AD to match VM hostname stored within the VCL database")); $h .= "</div>\n"; # tooltips return $h; @@ -510,6 +518,7 @@ class ADdomain extends Resource { $return["password"] = $_POST['password']; $return["password2"] = $_POST['password2']; $return["dnsservers"] = processInputVar("dnsservers", ARG_STRING); + $return["useDatabaseHostnamesForComputerObjects"] = $_POST['useDatabaseHostnamesForComputerObjects']; if(! preg_match("/^([A-Za-z0-9-!@#$%^&\*\(\)_=\+\[\]{}\\\|:;,\.\/\?~` ]){2,30}$/", $return['name'])) { $return['error'] = 1; diff --git a/web/.ht-inc/utils.php b/web/.ht-inc/utils.php index 763e4b2..c81f7bf 100644 --- a/web/.ht-inc/utils.php +++ b/web/.ht-inc/utils.php @@ -9488,7 +9488,8 @@ function getNATports($resid) { /// \b domaindnsname\n /// \b username\n /// \b dnsservers\n -/// \b secretid +/// \b secretid\n +/// \b useDatabaseHostnamesForComputerObjects\n /// /// \brief builds an array of AD domains /// @@ -9502,7 +9503,8 @@ function getADdomains($addomainid=0) { . "ad.domainDNSName AS domaindnsname, " . "ad.username, " . "ad.dnsServers AS dnsservers, " - . "ad.secretid " + . "ad.secretid, " + . "ad.useDatabaseHostnamesForComputerObjects AS useDatabaseHostnamesForComputerObjects " . "FROM addomain ad, " . "affiliation a, " . "user u, " diff --git a/web/js/resources/addomain.js b/web/js/resources/addomain.js index 4579a24..158d97c 100644 --- a/web/js/resources/addomain.js +++ b/web/js/resources/addomain.js @@ -41,11 +41,12 @@ function inlineEditResourceCB(data, ioArgs) { dojo.byId('editresid').value = data.items.rscid; dijit.byId('name').set('value', data.items.data.name); dijit.byId('owner').set('value', data.items.data.owner); - 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) + } dijit.byId('password').set('value', '********'); dijit.byId('password2').set('value', 'xxxxxxxx'); @@ -58,7 +59,7 @@ function inlineEditResourceCB(data, ioArgs) { } function resetEditResource() { - var fields = ['name', 'owner', 'domaindnsname', 'username', 'password', 'password2', 'dnsservers']; + var fields = ['name', 'owner', 'domaindnsname', 'username', 'password', 'password2', 'usedbhostnames', 'dnsservers']; for(var i = 0; i < fields.length; i++) { dijit.byId(fields[i]).reset(); } @@ -89,7 +90,13 @@ function saveResource() { dojo.byId('addeditdlgerrmsg').innerHTML = _('Passwords do not match'); return; } - + // update useDatabaseHostnamesForComputerObjects + if(dijit.byId('usedbhostnames').get('checked')) { + data['useDatabaseHostnamesForComputerObjects'] = 1; + } + else { + data['useDatabaseHostnamesForComputerObjects'] = 0; + } dijit.byId('addeditbtn').set('disabled', true); RPCwrapper(data, saveResourceCB, 1); }
