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

xADOrganizationalUnit: Unhandled Exception when the Path Property specifies a Non-Existing Path #408

Closed
X-Guardian opened this issue Jul 2, 2019 · 0 comments · Fixed by #413
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub

Comments

@X-Guardian
Copy link
Contributor

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

An unhandled exception occurs when deploying an xADOrganizationalUnit resource that specifies a Path property that doesn't exists within Active Directory. It is not clear from the error that it is the path not existing that has caused the exception.

Verbose logs showing the problem

VERBOSE: [DC01-SRV-EUW1]: LCM:  [ Start  Resource ]  [[xADOrganizationalUnit]Admin Accounts]
VERBOSE: [DC01-SRV-EUW1]: LCM:  [ Start  Test     ]  [[xADOrganizationalUnit]Admin Accounts]
VERBOSE: [DC01-SRV-EUW1]:                            [[xADOrganizationalUnit]Admin Accounts] Retrieving OU 'Admin Accounts'.
Directory object not found
    + CategoryInfo          : ObjectNotFound: (:) [], CimException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,M
   icrosoft.ActiveDirectory.Management.Commands.GetADOrganizationalUnit

Suggested solution to the issue

Catch this error from the Get-ADOrganizationalUnit function call in Get-TargetResource and throw a more detailed exception.

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

Configuration xADOrganizationalUnit
{
    param ()

    Import-DscResource -Module xActiveDirectory

    Node localhost
    {
        xADOrganizationalUnit 'Admin Accounts'
        {
            Name = 'Admin Accounts'
            Path = 'ou=This ou does not exist,dc=contoso,dc=com'
        }
    }
}

The operating system the target node is running

OsName               : Microsoft Windows Server 2019 Standard Evaluation
OsOperatingSystemSKU : 79
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

Name                           Value
----                           -----
PSVersion                      5.1.17763.316
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.316
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version of the DSC module that was used ('dev' if using current dev branch)

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.0.0.0    xActiveDirectory
@johlju johlju added bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community. labels Jul 2, 2019
@johlju johlju added this to To do in All issues and PR's via automation Jul 2, 2019
All issues and PR's automation moved this from To do to Done Jul 5, 2019
johlju pushed a commit that referenced this issue Jul 5, 2019
…es a Non-Existing Path (#413)

- Changes to xADOrganizationalUnit
  - Catch exception when the path property specifies a non-existing path (issue #408)
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label Jul 5, 2019
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. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub
Projects
Development

Successfully merging a pull request may close this issue.

2 participants