diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm
index a9d3f8971..b21b7eb78 100644
--- a/xCAT-server/lib/perl/xCAT/Template.pm
+++ b/xCAT-server/lib/perl/xCAT/Template.pm
@@ -34,6 +34,7 @@ my $idir;
my $node;
my %loggedrealms;
my $lastmachinepassdata;
+my $localadminenabled; #indicate whether Windows template has local logins enabled or not
my %tab_replacement=(
"noderes:nfsserver"=>"noderes:xcatmaster",
"noderes:tftpserver"=>"noderes:xcatmaster",
@@ -190,6 +191,8 @@ sub subvars {
$inc =~ s/#WINTIMEZONE#/xCAT::TZUtils::get_wintimezone()/eg;
$inc =~ s/#WINPRODKEY:([^#]+)#/get_win_prodkey($1)/eg;
$inc =~ s/#WINADJOIN#/windows_join_data()/eg;
+ $inc =~ s/#WINACCOUNTDATA#/windows_account_data()/eg;
+ $inc =~ s/#WINDISABLENULLADMIN#/windows_disable_null_admin()/eg;
$inc =~ s/#HOSTNAME#/$node/g;
my $nrtab = xCAT::Table->new("noderes");
@@ -259,6 +262,39 @@ sub subvars {
close($outh);
return 0;
}
+sub windows_disable_null_admin {
+#in the event where windows_account_data has not set an administrator user, we explicitly disable the administrator user
+ unless ($localadminenabled) {
+ return '
+
+ 100
+ cmd /c %systemroot%\system32\net.exe user Administrator /active:no
+
+';
+ }
+ return "";
+}
+sub windows_account_data {
+#this will add domain accounts if configured to be in active directory
+#it will also put in an administrator password for local account, *if* specified
+ my $passtab = xCAT::Table->new('passwd',-create=>0);
+ my $useraccountxml="";
+ $localadminenabled=0;
+ if ($passtab) {
+ my $passent = $passtab->getAttribs({key=>"system",username=>"Administrator"},['password']);
+ if ($passent and $passent->{password}) {
+ $useraccountxml="\n".$passent->{password}."\ntrue\n\n";
+ $useraccountxml.="\n";
+ $localadminenabled=1;
+ }
+ }
+
+ unless ($::XCATSITEVALS{directoryprovider} eq "activedirectory" and $::XCATSITEVALS{domain}) {
+ return $useraccountxml;
+ }
+ $useraccountxml.="\n\nAdministrators\nDomain Admins\n\n".$::XCATSITEVALS{domain}."\n\n\n";
+ return $useraccountxml;
+}
#this will examine table data, decide *if* a Microsoft-Windows-UnattendedJoin is warranted
#there are two variants in how to proceed:
#-Hide domain administrator from node: xCAT will use MACHINEPASSWORD to do joining to AD. Currently requires SSL be enabled on DC. Samba 4 TODO
diff --git a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl
index 08569fe28..9f6a45654 100644
--- a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl
+++ b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl
@@ -108,6 +108,9 @@
+
+ #WINDISABLENULLADMIN#
+
#TABLE:nodelist:$NODE:node#
diff --git a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi
index 070cc9255..8c7fcbb8b 100644
--- a/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi
+++ b/xCAT-server/share/xcat/install/windows/datacenter.win2012.x86_64.tmpl.uefi
@@ -120,6 +120,9 @@
+
+ #WINDISABLENULLADMIN#
+
#TABLE:nodelist:$NODE:node#
diff --git a/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl b/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl
index 52d37ea1d..5503e9688 100644
--- a/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl
+++ b/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl
@@ -107,6 +107,9 @@
+
+ #WINDISABLENULLADMIN#
+
#TABLE:nodelist:$NODE:node#
diff --git a/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl.uefi b/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl.uefi
index 9928fca3b..c483f6b7e 100644
--- a/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl.uefi
+++ b/xCAT-server/share/xcat/install/windows/hypervisor.hyperv2012.x86_64.tmpl.uefi
@@ -117,6 +117,9 @@
+
+ #WINDISABLENULLADMIN#
+
#TABLE:nodelist:$NODE:node#
diff --git a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl
index f208d2040..b4acfd446 100644
--- a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl
+++ b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl
@@ -108,6 +108,9 @@
+
+ #WINDISABLENULLADMIN#
+
#TABLE:nodelist:$NODE:node#
diff --git a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi
index d189ecb6f..ba8a33645 100644
--- a/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi
+++ b/xCAT-server/share/xcat/install/windows/standard.win2012.x86_64.tmpl.uefi
@@ -118,6 +118,9 @@
+
+ #WINDISABLENULLADMIN#
+
#TABLE:nodelist:$NODE:node#