Skip to content

Commit

Permalink
New transforms and enhanced transform loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jformacek committed Dec 26, 2020
1 parent 73b3d7f commit e7e6bb4
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 4 deletions.
4 changes: 2 additions & 2 deletions S.DS.P.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ More about attribute transforms and how to create them: https://github.com/jform

[CmdletBinding()]
param (
[Parameter(Mandatory,ParameterSetName='Name')]
[Parameter(Mandatory,ParameterSetName='Name', Position=0)]
[string]
#Name of the transform
$Name,
Expand All @@ -1253,7 +1253,7 @@ More about attribute transforms and how to create them: https://github.com/jform
#Name of the attribute that will be processed by transform
#If not specified, transform will be registered on all supported attributes
$AttributeName,
[Parameter(Mandatory,ValueFromPipeline,ParameterSetName='TransformObject')]
[Parameter(Mandatory,ValueFromPipeline,ParameterSetName='TransformObject', Position=0)]
[PSCustomObject]
$Transform
)
Expand Down
2 changes: 1 addition & 1 deletion Transforms/Integer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if($FullLoad)
}

#add attributes that can be used with this transform
$SupportedAttributes = @('msDS-Approx-Immed-Subordinates','codePage','countryCode','logonCount')
$SupportedAttributes = @('codePage','countryCode','logonCount','msDS-Approx-Immed-Subordinates','ms-DS-KeyVersionNumber','ms-DS-ManagedPasswordInterval')

# This is mandatory definition of transform that is expected by transform architecture
$prop=[Ordered]@{
Expand Down
42 changes: 42 additions & 0 deletions Transforms/quotaUsage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

[CmdletBinding()]
param (
[Parameter()]
[Switch]
$FullLoad
)

$codeBlock=[PSCustomObject][Ordered]@{
SupportedAttributes=@('msDS-TopQuotaUsage')
OnLoad = $null
OnSave = $null
}

$codeBlock.OnLoad = {
param(
[string[]]$Values
)
Process
{
foreach($Value in $Values)
{
[xml]$Value.SubString(0,$Value.Length-2)
}
}
}
$codeBlock.OnSave = {
param(
[object[]]$Values
)

Process
{
foreach($Value in $Values)
{
$Value.InnerXml
}
}
}

$codeBlock

65 changes: 65 additions & 0 deletions Transforms/searchFlags.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[CmdletBinding()]
param (
[Parameter()]
[Switch]
$FullLoad
)

if($FullLoad)
{
# From [MS-ADTS]/2.2.9
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/7c1cdf82-1ecc-4834-827e-d26ff95fb207
Add-Type @'
using System;
[Flags]
public enum SearchFlags
{
ATTINDEX = 0x1,
PDNTATTINDEX = 0x2,
ANR = 0x4,
PRESERVEONDELETE = 0x8,
COPY = 0x10,
TUPLEINDEX = 0x20,
SUBTREEATTINDEX = 0x40,
CONFIDENTIAL = 0x80,
NEVERVALUEAUDIT = 0x100,
RODCFilteredAttribute = 0x200,
EXTENDEDLINKTRACKING = 0x400,
BASEONLY = 0x800,
PARTITIONSECRET = 0x1000,
}
'@
}

$codeBlock=[PSCustomObject][Ordered]@{
SupportedAttributes=@('searchFlags')
OnLoad = $null
OnSave = $null
}
$codeBlock.OnLoad = {
param(
[object[]]$Values
)
Process
{
foreach($Value in $Values)
{
[SearchFlags].GetEnumValues().ForEach({if((([int32]$Value) -band $_) -eq $_) {"$_"}})
}
}
}
$codeBlock.OnSave = {
param(
[object[]]$Values
)

Process
{
$retVal = 0
$Values.ForEach({ [SearchFlags]$val=$_; $retVal+=$val})
$retVal

}
}
$codeBlock

2 changes: 1 addition & 1 deletion Transforms/securityDescriptor.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if($FullLoad)

$prop=[Ordered]@{
BinaryInput=$true
SupportedAttributes=@('ntSecurityDescriptor','msDS-AllowedToActOnBehalfOfOtherIdentity')
SupportedAttributes=@('msDS-AllowedToActOnBehalfOfOtherIdentity','ms-DS-GroupMSAMembership','ntSecurityDescriptor')
OnLoad = $null
OnSave = $null
}
Expand Down
65 changes: 65 additions & 0 deletions Transforms/systemFlags.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[CmdletBinding()]
param (
[Parameter()]
[Switch]
$FullLoad
)

if($FullLoad)
{
# From [MS-ADTS]/2.2.10
# https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/1e38247d-8234-4273-9de3-bbf313548631
Add-Type @'
using System;
[Flags]
public enum SystemFlags : uint
{
DISALLOW_DELETE = 0x80000000,
CONFIG_ALLOW_RENAME = 0x40000000,
CONFIG_ALLOW_MOVE = 0x20000000,
CONFIG_ALLOW_LIMITED_MOVE = 0x10000000,
DOMAIN_DISALLOW_RENAME = 0x8000000,
DOMAIN_DISALLOW_MOVE = 0x4000000,
DISALLOW_MOVE_ON_DELETE = 0x2000000,
ATTR_IS_RDN = 0x20,
SCHEMA_BASE_OBJECT = 0x10,
ATTR_IS_OPERATIONAL = 0x8,
ATTR_IS_CONSTRUCTED = 0x4,
PARTIAL_SET_MEMBER = 0x2,
NOT_REPLICATED = 0x1
}
'@
}

$codeBlock=[PSCustomObject][Ordered]@{
SupportedAttributes=@('systemFlags')
OnLoad = $null
OnSave = $null
}
$codeBlock.OnLoad = {
param(
[object[]]$Values
)
Process
{
foreach($Value in $Values)
{
[SystemFlags].GetEnumValues().ForEach({if(($Value -band $_) -eq $_) {"$_"}})
}
}
}
$codeBlock.OnSave = {
param(
[object[]]$Values
)

Process
{
$retVal = 0
$Values.ForEach({ [SystemFlags]$val=$_; $retVal+=$val})
$retVal

}
}
$codeBlock

0 comments on commit e7e6bb4

Please sign in to comment.