Skip to content

Commit a590bb9

Browse files
author
Rich Siegel
committed
ADManagedServiceAccount: add ServicePrincipalNames setting
* This is a string array and specifies Service Principal Names for an AD Managed Service Account
1 parent 8ae460a commit a590bb9

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ For older change log history see the [historic changelog](HISTORIC_CHANGELOG.md)
1111
- ADManagedServiceAccount
1212
- New parameter TrustedForDelegation for Kerberos Delegation
1313
([issue #717](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/717)).
14+
- New parameter TrustedForDelegation for Service Principal Name
15+
([issue #717](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/717)).
1416
- ADDomainController
1517
- New parameter UseExistingAccount for attaching a server to an existing RODC account.
1618
([issue #711](https://github.com/dsccommunity/ActiveDirectoryDsc/issues/711)).

source/DSCResources/MSFT_ADManagedServiceAccount/MSFT_ADManagedServiceAccount.psm1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function Get-TargetResource
9696
'Enabled'
9797
'PrincipalsAllowedToRetrieveManagedPassword'
9898
'KerberosEncryptionType'
99+
'ServicePrincipalNames'
99100
'TrustedForDelegation'
100101
)
101102
}
@@ -159,6 +160,7 @@ function Get-TargetResource
159160
DistinguishedName = $adServiceAccount.DistinguishedName
160161
Enabled = $adServiceAccount.Enabled
161162
KerberosEncryptionType = $adServiceAccount.KerberosEncryptionType -split (', ')
163+
ServicePrincipalNames = $adServiceAccount.ServicePrincipalNames -split (', ')
162164
TrustedForDelegation = $adServiceAccount.TrustedForDelegation
163165
ManagedPasswordPrincipals = $managedPasswordPrincipals
164166
MembershipAttribute = $MembershipAttribute
@@ -178,6 +180,7 @@ function Get-TargetResource
178180
DistinguishedName = $null
179181
Enabled = $false
180182
KerberosEncryptionType = @()
183+
ServicePrincipalNames = @()
181184
TrustedForDelegation = $null
182185
ManagedPasswordPrincipals = @()
183186
MembershipAttribute = $MembershipAttribute
@@ -227,6 +230,9 @@ function Get-TargetResource
227230
This value sets the encryption types supported flags of the Active Directory msDS-SupportedEncryptionTypes
228231
attribute.
229232
233+
.PARAMETER ServicePrincipalNames
234+
Specifies the service principal names for the user account.
235+
230236
.PARAMETER TrustedForDelegation
231237
Specifies whether an account is trusted for Kerberos delegation. Default value is $false.
232238
@@ -300,6 +306,10 @@ function Test-TargetResource
300306
[System.String[]]
301307
$KerberosEncryptionType,
302308

309+
[Parameter()]
310+
[System.String[]]
311+
$ServicePrincipalNames,
312+
303313
[Parameter()]
304314
[ValidateNotNull()]
305315
[System.Boolean]
@@ -431,6 +441,9 @@ function Test-TargetResource
431441
This value sets the encryption types supported flags of the Active Directory msDS-SupportedEncryptionTypes
432442
attribute.
433443
444+
.PARAMETER ServicePrincipalNames
445+
Specifies the service principal names for the user account.
446+
434447
.PARAMETER TrustedForDelegation
435448
Specifies whether an account is trusted for Kerberos delegation. Default value is $false.
436449
@@ -512,6 +525,10 @@ function Set-TargetResource
512525
[System.String[]]
513526
$KerberosEncryptionType,
514527

528+
[Parameter()]
529+
[System.String[]]
530+
$ServicePrincipalNames,
531+
515532
[Parameter()]
516533
[ValidateNotNull()]
517534
[System.Boolean]

source/DSCResources/MSFT_ADManagedServiceAccount/MSFT_ADManagedServiceAccount.schema.mof

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class MSFT_ADManagedServiceAccount : OMI_BaseResource
1010
[Write, Description("Specifies the Active Directory Domain Controller instance to use to perform the task. This is only required if not executing the task on a domain controller.")] String DomainController;
1111
[Write, Description("Specifies whether the user account is created or deleted. If not specified, this value defaults to Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
1212
[Write, Description("Specifies which Kerberos encryption types the account supports when creating service tickets. This value sets the encryption types supported flags of the Active Directory msDS-SupportedEncryptionTypes attribute."),ValueMap{"None","RC4","AES128","AES256"}, Values{"None","RC4","AES128","AES256"}] String KerberosEncryptionType[];
13+
[Write, Description("Specifies the service principal names for the user account.")] String ServicePrincipalNames[];
1314
[Write, Description("Specifies whether an account is trusted for Kerberos delegation. Default value is $false.")] Boolean TrustedForDelegation;
1415
[Write, Description("Specifies the membership policy for systems which can use a group managed service account. (ldapDisplayName 'msDS-GroupMSAMembership'). Only used when 'Group' is selected for 'AccountType'.")] String ManagedPasswordPrincipals[];
1516
[Write, Description("Active Directory attribute used to perform membership operations for Group Managed Service Accounts (gMSA). If not specified, this value defaults to SamAccountName."), ValueMap{"SamAccountName","DistinguishedName","ObjectGUID","ObjectSid"}, Values{"SamAccountName","DistinguishedName","ObjectGUID","ObjectSid"}] String MembershipAttribute;

source/DSCResources/MSFT_ADManagedServiceAccount/en-US/about_ADManagedServiceAccount.help.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
Allowed values: None, RC4, AES128, AES256
4646
Specifies which Kerberos encryption types the account supports when creating service tickets. This value sets the encryption types supported flags of the Active Directory msDS-SupportedEncryptionTypes attribute.
4747

48+
.PARAMETER ServicePrincipalNames
49+
Write - StringArray
50+
Specifies the service principal names for the user account.
51+
4852
.PARAMETER TrustedForDelegation
4953
Write - Boolean
5054
Specifies whether an account is trusted for Kerberos delegation. Default value is $false.

tests/Unit/MSFT_ADManagedServiceAccount.Tests.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ try
7777
DisplayName = 'TestSMSA'
7878
Enabled = $true
7979
KerberosEncryptionType = 'RC4', 'AES128', 'AES256'
80+
ServicePrincipalNames = 'MSSQLSvc/Node1.contoso.com','HTTP/Node1','HTTP/Node1.contoso.com'
8081
TrustedForDelegation = $false
8182
ManagedPasswordPrincipals = @()
8283
MembershipAttribute = 'SamAccountName'
@@ -94,6 +95,7 @@ try
9495
ManagedPasswordPrincipals = @()
9596
MembershipAttribute = $mockAdServiceAccountStandalone.MembershipAttribute
9697
KerberosEncryptionType = @()
98+
ServicePrincipalNames = @()
9799
Ensure = 'Absent'
98100
}
99101

@@ -102,6 +104,7 @@ try
102104
Description = 'Changed description'
103105
DisplayName = 'Changed displayname'
104106
KerberosEncryptionType = 'AES128', 'AES256'
107+
ServicePrincipalNames = 'MSSQLSvc/Node1.contoso.com','HTTP/Node1'
105108
ManagedPasswordPrincipals = $mockADUSer.SamAccountName
106109
}
107110

@@ -114,6 +117,7 @@ try
114117
DisplayName = 'TestGMSA'
115118
Enabled = $true
116119
KerberosEncryptionType = 'RC4', 'AES128', 'AES256'
120+
ServicePrincipalNames = 'MSSQLSvc/Node1.contoso.com','HTTP/Node1','HTTP/Node1.contoso.com'
117121
TrustedForDelegation = $true
118122
ManagedPasswordPrincipals = $mockADUSer.SamAccountName, $mockADComputer.SamAccountName
119123
MembershipAttribute = 'SamAccountName'
@@ -131,6 +135,7 @@ try
131135
ManagedPasswordPrincipals = @()
132136
MembershipAttribute = $mockAdServiceAccountGroup.MembershipAttribute
133137
KerberosEncryptionType = @()
138+
ServicePrincipalNames = @()
134139
TrustedForDelegation = $null
135140
Ensure = 'Absent'
136141
}
@@ -142,6 +147,7 @@ try
142147
DistinguishedName = $mockAdServiceAccountStandalone.DistinguishedName
143148
Enabled = $mockAdServiceAccountStandalone.Enabled
144149
KerberosEncryptionType = $mockAdServiceAccountStandalone.KerberosEncryptionType
150+
ServicePrincipalNames = $mockAdServiceAccountStandalone.ServicePrincipalNames
145151
TrustedForDelegation = $mockAdServiceAccountStandalone.TrustedForDelegation
146152
Name = $mockAdServiceAccountStandalone.ServiceAccountName
147153
ObjectClass = 'msDS-ManagedServiceAccount'
@@ -158,6 +164,7 @@ try
158164
DistinguishedName = $mockAdServiceAccountGroup.DistinguishedName
159165
Enabled = $mockAdServiceAccountGroup.Enabled
160166
KerberosEncryptionType = $mockAdServiceAccountGroup.KerberosEncryptionType
167+
ServicePrincipalNames = $mockAdServiceAccountGroup.ServicePrincipalNames
161168
TrustedForDelegation = $mockAdServiceAccountGroup.TrustedForDelegation
162169
Name = $mockAdServiceAccountGroup.ServiceAccountName
163170
ObjectClass = 'msDS-GroupManagedServiceAccount'
@@ -183,6 +190,7 @@ try
183190
Credential = $mockCredentials
184191
DomainController = $mockDomainController
185192
KerberosEncryptionType = 'RC4', 'AES128', 'AES256'
193+
ServicePrincipalNames = 'MSSQLSvc/Node1.contoso.com','HTTP/Node1','HTTP/Node1.contoso.com'
186194
TrustedForDelegation = $false
187195

188196
}
@@ -202,6 +210,7 @@ try
202210
Credential = $mockCredentials
203211
DomainController = $mockDomainController
204212
KerberosEncryptionType = 'RC4', 'AES128', 'AES256'
213+
ServicePrincipalNames = 'MSSQLSvc/Node1.contoso.com','HTTP/Node1','HTTP/Node1.contoso.com'
205214
TrustedForDelegation = $false
206215
}
207216

@@ -218,6 +227,7 @@ try
218227
ManagedPasswordPrincipals = @()
219228
MembershipAttribute = 'SamAccountName'
220229
KerberosEncryptionType = @()
230+
ServicePrincipalNames = @()
221231
TrustedForDelegation = $null
222232
}
223233

@@ -434,6 +444,7 @@ try
434444
Description = $mockAdServiceAccountStandalone.Description
435445
DisplayName = $mockAdServiceAccountStandalone.DisplayName
436446
KerberosEncryptionType = $mockAdServiceAccountStandalone.KerberosEncryptionType
447+
ServicePrincipalNames = $mockAdServiceAccountStandalone.ServicePrincipalNames
437448
ManagedPasswordPrincipals = $mockAdServiceAccountStandalone.ManagedPasswordPrincipals
438449
MembershipAttribute = $mockAdServiceAccountStandalone.MembershipAttribute
439450
Ensure = $mockAdServiceAccountStandalone.Ensure
@@ -567,6 +578,7 @@ try
567578
Ensure = $mockAdServiceAccountStandAlone.Ensure
568579
DisplayName = $mockAdServiceAccountStandAlone.DisplayName
569580
KerberosEncryptionType = $mockAdServiceAccountStandAlone.KerberosEncryptionType
581+
ServicePrincipalNames = $mockAdServiceAccountStandalone.ServicePrincipalNames
570582
}
571583

572584
$setTargetResourceParametersStandAloneAbsent = $setTargetResourceParametersStandAlone.Clone()
@@ -583,6 +595,7 @@ try
583595
ManagedPasswordPrincipals = $mockAdServiceAccountGroup.ManagedPasswordPrincipals
584596
DisplayName = $mockAdServiceAccountGroup.Name.DisplayName
585597
KerberosEncryptionType = $mockAdServiceAccountGroup.KerberosEncryptionType
598+
ServicePrincipalNames = $mockAdServiceAccountGroup.ServicePrincipalNames
586599
}
587600
Context 'When the Resource should be Present' {
588601

0 commit comments

Comments
 (0)