Skip to content
Draft
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- ActiveDirectoryCSDsc
- `ActiveDirectoryCSDsc`
- Automatically publish documentation to GitHub Wiki - Fixes [Issue #122](https://github.com/dsccommunity/ActiveDirectoryCSDsc/issues/122).
- Revert Pester to non-prerelease.
- Use DscResource.Base pre-release.
Expand All @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Tests` - Migrate all tests to Pester 5.
- Include module file in code coverage.
- Add RootModule to Module psd1.
- AdcsAuthorityInformationAccess
- `AdcsAuthorityInformationAccess`
- Removed `AllowRestartService` parameter from compared settings, force `Get-CaAiaUriList`
to return unmangled `System.String[]` with single values.
Fixes [Issue #128](https://github.com/dsccommunity/ActiveDirectoryCSDsc/issues/128)
Expand All @@ -35,6 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Move to Private function.
- `Restart-ServiceIfExists`
- Change Write-Verbose to Write-Debug.
- `AdcsOnlineResponder`
- Convert to class-based resource [#155](https://github.com/dsccommunity/ActiveDirectoryCSDsc/issues/155).

### Added

Expand Down
7 changes: 6 additions & 1 deletion RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
AllowPrerelease = $true
}
}
'DscResource.Common' = 'latest'
'DscResource.Common' = @{
Version = 'latest'
Parameters = @{
AllowPrerelease = $true
}
}

# Analyzer rules
'DscResource.AnalyzerRules' = 'latest'
Expand Down
138 changes: 138 additions & 0 deletions source/Classes/020.AdcsOnlineResponder.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<#
.SYNOPSIS
The `AdcsOnlineResponder` DSC resource is used to configure the
ADCS Online Responder after the feature has been installed on the server.

.DESCRIPTION
This resource can be used to install an ADCS Online Responder after the feature
has been installed on the server.
Using this DSC Resource to configure an ADCS Certificate Authority assumes that
the ```ADCS-Online-Responder``` feature has already been installed.

Comment on lines +6 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Fix inaccurate wording and add required “Requirements” and “Known issues” sections in .DESCRIPTION.

“Certificate Authority” is incorrect here; this resource configures the Online Responder. Also add the required sections per guidelines.

     .DESCRIPTION
-        This resource can be used to install an ADCS Online Responder after the feature
-        has been installed on the server.
-        Using this DSC Resource to configure an ADCS Certificate Authority assumes that
-        the ```ADCS-Online-Responder``` feature has already been installed.
+        This resource can be used to install and configure an ADCS Online Responder after
+        the Windows feature has been installed on the server.
+        Using this DSC resource to configure an ADCS Online Responder assumes that the
+        'ADCS-Online-Responder' Windows feature is already installed.
+
+        ## Requirements
+            - Windows Server with Active Directory Certificate Services available.
+            - ADCSDeployment PowerShell module present on the node.
+            - 'ADCS-Online-Responder' feature installed.
+
+        ## Known issues
+            All issues are not listed here, see all open issues:
+            https://github.com/dsccommunity/ActiveDirectoryCSDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+AdcsOnlineResponder
🤖 Prompt for AI Agents
In source/Classes/020.AdcsOnlineResponder.ps1 around lines 6 to 11, the
.DESCRIPTION text incorrectly refers to a "Certificate Authority" and lacks
required "Requirements" and "Known issues" sections; update the description to
say this resource installs and configures an ADCS Online Responder after the
Windows feature is installed, change wording to reference the
'ADCS-Online-Responder' Windows feature (no triple-backticks), and append a
Requirements section listing: Windows Server with AD CS available;
ADCSDeployment PowerShell module present on the node; 'ADCS-Online-Responder'
feature installed, plus a Known issues section that points to the repository
issues URL for AdcsOnlineResponder.

.PARAMETER IsSingleInstance
Specifies the resource is a single instance, the value must be 'Yes'.

.PARAMETER Credential
If the Online Responder service is configured to use Standalone certification authority,
then an account that is a member of the local Administrators on the CA is required. If
the Online Responder service is configured to use an Enterprise CA, then an account that
is a member of Domain Admins is required.

.PARAMETER Ensure
Specifies whether the Online Responder feature should be installed or uninstalled.

.PARAMETER Reasons
Returns the reason a property is not in desired state.

.NOTES
Used Functions:
Name | Module
----------------------------- |-------------------
Install-AdcsOnlineResponder | ADCSDeployment
Uninstall-AdcsOnlineResponder | ADCSDeployment
Assert-Module | DscResource.Common
New-InvalidOperationException | DscResource.Common
#>

[DscResource()]
class AdcsOnlineResponder : ResourceBase
{
[DscProperty(Key)]
[System.String]
$IsSingleInstance = 'Yes'

[DscProperty(Mandatory)]
[System.Management.Automation.PSCredential]
[System.Management.Automation.Credential()]
$Credential

[DscProperty()]
[Ensure]
$Ensure = [Ensure]::Present

[DscProperty(NotConfigurable)]
[AdcsReason[]]
$Reasons

AdcsOnlineResponder () : base ($PSScriptRoot)
{
# These properties will not be enforced.
$this.ExcludeDscProperties = @(
'IsSingleInstance'
'Credential'
)
}

[AdcsOnlineResponder] Get()
{
# Call the base method to return the properties.
return ([ResourceBase] $this).Get()
}

# Base method Get() calls this method to get the current state as a Hashtable.
[System.Collections.Hashtable] GetCurrentState([System.Collections.Hashtable] $properties)
{
try
{
$null = Install-AdcsOnlineResponder -Credential $this.Credential -WhatIf

return @{}
}
catch
{
if ($_.Exception.ToString() -match 'OnlineResponderSetupException$')
{
return @{
IsSingleInstance = $this.IsSingleInstance
Credential = $this.Credential
}
}

return New-InvalidOperationException -Message $this.localizedData.ErrorGetCurrentState -ErrorRecord $_
}
}

[void] Set()
{
# Call the base method to enforce the properties.
([ResourceBase] $this).Set()
}

<#
Base method Set() call this method with the properties that should be
enforced and that are not in desired state.
#>
hidden [void] Modify([System.Collections.Hashtable] $properties)
{
$errorMessage = ''

if ($properties.ContainsKey('Ensure') -and $properties.Ensure -eq [Ensure]::Absent)
{
$errorMessage = (Uninstall-AdcsOnlineResponder -Force).ErrorString
}
else
{
$errorMessage = (Install-AdcsOnlineResponder -Credential $this.Credential -Force).ErrorString
}

if (-not [System.String]::IsNullOrEmpty($errorMessage))
{
New-InvalidOperationException -Message $errorMessage
}
}

[System.Boolean] Test()
{
# Call the base method to test all of the properties that should be enforced.
return ([ResourceBase] $this).Test()
}

<#
Base method Assert() call this method with the properties that was assigned
a value.
#>
hidden [void] AssertProperties([System.Collections.Hashtable] $properties)
{
Assert-Module -ModuleName 'ADCSDeployment'
}
}
Loading