Skip to content

Commit bffc5cd

Browse files
committed
Implemented a GPO check to prevent an endless reboot loop when CredSSP is configured via a GPO
1 parent d93730a commit bffc5cd

3 files changed

Lines changed: 58 additions & 8 deletions

File tree

lib/facter/credsspclientgpo.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#https://puppet.com/blog/starting-out-writing-custom-facts-windows
2+
Facter.add('credsspclientgpo') do
3+
confine :osfamily => :windows
4+
setcode do
5+
begin
6+
result=false
7+
value = nil
8+
Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Policies\Microsoft\Windows\WinRM\Client') do |regkey|
9+
value = regkey['AllowCredSSP']
10+
result=true
11+
end
12+
result
13+
rescue
14+
false
15+
end
16+
end
17+
end

lib/facter/credsspservicegpo.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#https://puppet.com/blog/starting-out-writing-custom-facts-windows
2+
Facter.add('credsspservicegpo') do
3+
confine :osfamily => :windows
4+
setcode do
5+
begin
6+
result=false
7+
value = nil
8+
Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Policies\Microsoft\Windows\WinRM\Service') do |regkey|
9+
value = regkey['AllowCredSSP']
10+
result=true
11+
end
12+
result
13+
rescue
14+
false
15+
end
16+
end
17+
end

manifests/install.pp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,32 @@
55
when => refreshed
66
}
77

8-
dsc_xcredssp{ 'Server':
9-
dsc_ensure => 'Present',
10-
dsc_role => 'Server',
11-
notify => Reboot['after_run']
8+
#Implemented a GPO check to prevent an endless reboot loop when CredSSP is configured via a GPO
9+
if (!$credsspservicegpo) {
10+
dsc_xcredssp{ 'Server':
11+
dsc_ensure => 'Present',
12+
dsc_role => 'Server',
13+
notify => Reboot['after_run']
14+
}
15+
}
16+
else {
17+
notify { 'CredSSPServic#Implemented a GPO check to prevent an endless reboot loop when CredSSP is configured via a GPOeAlreadyConfigured':
18+
message => 'CredSSP already configured by GPO. Unauthorized to overide GPO configuration. Please check that CredSSP service is allowed on this Computer.'
19+
}
1220
}
1321

14-
dsc_xcredssp{ 'Client':
15-
dsc_ensure => 'Present',
16-
dsc_role => 'Client',
17-
dsc_delegatecomputers => '*'
22+
#Implemented a GPO check to prevent an endless reboot loop when CredSSP is configured via a GPO
23+
if (!$credsspclientgpo) {
24+
dsc_xcredssp{ 'Client':
25+
dsc_ensure => 'Present',
26+
dsc_role => 'Client',
27+
dsc_delegatecomputers => '*'
28+
}
29+
}
30+
else {
31+
notify { 'CredSSPClientAlreadyConfigured':
32+
message => 'CredSSP already configured by GPO. Unauthorized to overide GPO configuration. Please check that CredSSP client is allowed on this Computer.'
33+
}
1834
}
1935

2036
#Ensure IIS is not installed on the system to avoid conflicts with Broker Service

0 commit comments

Comments
 (0)