Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## v0.6.1 - TBD

+ Remove length check for `sAMAccountName` when used in the `-Identity` parameter

## v0.6.0 - 2025-03-12

+ Raised minimum PowerShell version to 7.4
Expand Down
2 changes: 1 addition & 1 deletion src/PSOpenAD/ADIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal bool TryParseSamAccountName(string value, out LDAPFilter filter)
{
filter = new FilterPresent("");

Match m = Regex.Match(value, @"^(?:[^:*?""<>|\/\\]+\\)?(?<username>[^;:""<>|?,=\*\+\\\(\)]{1,20})$");
Match m = Regex.Match(value, @"^(?:[^:*?""<>|\/\\]+\\)?(?<username>[^;:""<>|?,=\*\+\\\(\)]+)$");
if (m.Success)
{
string username = m.Groups["username"].Value;
Expand Down
1 change: 0 additions & 1 deletion src/PSOpenAD/PSOpenAD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Formats.Asn1" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="System.Management.Automation" Version="7.4.0" PrivateAssets="all" />
<InternalsVisibleTo Include="PSOpenADTests" />
<InternalsVisibleTo Include="$(AssemblyName).Module" />
Expand Down
27 changes: 27 additions & 0 deletions tests/Get-OpenADObject.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ Describe "Get-OpenADObject cmdlets" -Skip:(-not $PSOpenADSettings.Server) {
BeforeAll {
$session = New-TestOpenADSession
$dcName = @($session.DomainController -split '\.')[0]

$container = (New-OpenADObject -Session $session -Name "PSOpenAD-Test-$([Guid]::NewGuid().Guid)" -Type container -PassThru).DistinguishedName
}

AfterAll {
if ($container) {
Get-OpenADObject -Session $session -LDAPFilter '(objectClass=*)' -SearchBase $container |
Sort-Object -Property { $_.DistinguishedName.Length } -Descending |
Remove-OpenADObject -Session $session
}
Get-OpenADSession | Remove-OpenADSession
}

Expand Down Expand Up @@ -155,6 +162,26 @@ Describe "Get-OpenADObject cmdlets" -Skip:(-not $PSOpenADSettings.Server) {
}
}

It "Gets group with name greater than 23 characters" {
$longGroupName = "MyGroup-$('a' * 55)"
$groupParams = @{
Name = $longGroupName
Type = 'group'
Path = $container
OtherAttributes = @{
sAMAccountName = $longGroupName
}
PassThru = $true
Session = $session
}
$group = New-OpenADObject @groupParams
$actual = Get-OpenADGroup -Identity $longGroupName -Session $session
$actual.Name | Should -Be $longGroupName
$actual.DistinguishedName | Should -Be "CN=$longGroupName,$container"
$actual.SamAccountName | Should -Be $longGroupName
$group | Remove-OpenADObject
}

It "Requests a property that is not set" {
$group = Get-OpenADGroup -Session $session | Select-Object -ExpandProperty DistinguishedName -First 1
$actual = Get-OpenADGroup -Session $session -Identity $group -Property adminCount
Expand Down