Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADOrganizationalUnit: Cannot use single quote in the Name parameter #674

Closed
Borgquite opened this issue Mar 17, 2022 · 2 comments · Fixed by #677
Closed

ADOrganizationalUnit: Cannot use single quote in the Name parameter #674

Borgquite opened this issue Mar 17, 2022 · 2 comments · Fixed by #677
Labels
bug The issue is a bug.

Comments

@Borgquite
Copy link
Contributor

Borgquite commented Mar 17, 2022

Details of the scenario you tried and the problem that is occurring

When trying to create an 'ADOrganizationalUnit', if the 'Name' is set to a value with a single quote ' an error occurs

Verbose logs showing the problem

PowerShell DSC resource MSFT_ADOrganizationalUnit failed to execute Test-TargetResource functionality with error message: System.InvalidOperationException: Error getting OU 'N'Djamena'. (ADOU0014) ---> Microsoft.ActiveDirectory.Management.ADFilterParsingException: Error parsing query: 'Name -eq 'N'Djamena'' Error Message: 'syntax error' at position: '13'. at Microsoft.ActiveDirectory.Management.QueryParser.yyerror(String s) at Microsoft.ActiveDirectory.Management.QueryParser.yyparse() at Microsoft.ActiveDirectory.Management.Commands.ADGetCmdletBase`3.ADGetCmdletBaseBeginCSRoutine() --- End of inner exception stack trace ---

Suggested solution to the issue

Appears to be an escaping issue in the following code:
DSCResources/MSFT_ADOrganizationalUnit/MSFT_ADOrganizationalUnit.psm1 (line 49)
If the filter:
-Filter "Name -eq '$Name'"
was changed to:
-Filter "Name -eq [backtick]"$Name[backtick]""
(where [backtick] is `)
it might resolve. (If you try to escape the input in the configuration e.g. by setting 'Name' to 'N''Djamena' the error does not occur - but the OU itself is created as 'N''Djamena' and subsequent consistency checks fail).

I think double quotes would still need to be escaped but this should resolve for single quotes

The DSC configuration that is used to reproduce the issue (as detailed as possible)

ADOrganizationalUnit "NDjamena"
{
    Name = "N'Djamena"
    Path = "DC=domain,DC=name=DC=here"
    Ensure = "Present"
}

The operating system the target node is running

OsName : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture : 64-bit
WindowsVersion : 1809
WindowsBuildLabEx : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage : en-US
OsMuiLanguages : {en-US}

Version and build of PowerShell the target node is running

PSVersion 5.1.17763.2268
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.2268
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Version of the DSC module that was used

6.0.1

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. labels Mar 18, 2022
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Apr 30, 2022
@Borgquite
Copy link
Contributor Author

Thank you :)

@johlju
Copy link
Member

johlju commented May 3, 2022

You’re welcome 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants