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

xADComputer: Restoring from recycle bin fails #271

Closed
johlju opened this issue May 11, 2019 · 1 comment · Fixed by #272
Closed

xADComputer: Restoring from recycle bin fails #271

johlju opened this issue May 11, 2019 · 1 comment · Fixed by #272
Assignees
Labels
bug The issue is a bug.

Comments

@johlju
Copy link
Member

johlju commented May 11, 2019

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

Restoring from recycle bin fails if there are more than one object with the same name.

Verbose logs showing the problem

VERBOSE: [CLDC03]: LCM:  [ Start  Set      ]  [[xADComputer]Integration_Test]
VERBOSE: [CLDC03]:                            [[xADComputer]Integration_Test] Importing the module MSFT_xADComputer in force mode.
VERBOSE: [CLDC03]:                            [[xADComputer]Integration_Test] Retrieving the information about the computer account 'DSCINTEGTEST01' from Active Directory. (ADC0002)
VERBOSE: [CLDC03]:                            [[xADComputer]Integration_Test] The computer account 'DSCINTEGTEST01' is absent from Active Directory. (ADC0004)
VERBOSE: [CLDC03]:                            [[xADComputer]Integration_Test] Attempting to restore the computer object DSCINTEGTEST01 from recycle bin. (ADC0013)
VERBOSE: [CLDC03]:                            [[xADComputer]Integration_Test] Finding objects in the recycle bin matching the filter msDS-LastKnownRDN -eq "DSCINTEGTEST01" -and objectClass -eq "Computer" -and isDeleted -eq $true. (ADCOMMON0027)
VERBOSE: [CLDC03]:                            [[xADComputer]Integration_Test] Found object DSCINTEGTEST01 (Computer) in the recycle bin as System.Object[]. Attempting to restore the object. (ADCOMMON0028)
      [-] Should compile and apply the MOF without throwing 952ms
        Expected no exception to be thrown, but an exception "Cannot convert 'System.Object[]' to the type 'Microsoft.ActiveDirectory.Management.ADObject' required by parameter 'Identity'. Specified method is not supported." was thrown from C:\Source\xActiveDirectory\Tes
ts\Integration\MSFT_xADComputer.Integration.Tests.ps1:157 char:21
            + ...               Start-DscConfiguration @startDscConfigurationParameters
            +                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
        158:                 } | Should -Not -Throw
        at <ScriptBlock>, C:\Source\xActiveDirectory\Tests\Integration\MSFT_xADComputer.Integration.Tests.ps1: line 139
VERBOSE: An LCM method call arrived from computer CLDC03 with user sid S-1-5-21-1619467470-1459113476-3809063323-1103.

Suggested solution to the issue

Pick up the lastest changed object from the recycle bin using the property whenChanged.

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

        xADComputer 'Integration_Test'
        {
            Ensure                = 'Present'
            ComputerName          = $Node.ComputerName1
            RestoreFromRecycleBin = $true
        }

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

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)

dev

@johlju
Copy link
Member Author

johlju commented May 11, 2019

The same problem will occur for the objects User, Computer, Group, and Service Account. The fix is to change the Restore-ADCommonObject, and that will resolve all.

@johlju johlju added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels May 11, 2019
johlju added a commit to johlju/ActiveDirectoryDsc that referenced this issue May 11, 2019
- Changes to xADComputer
  - Restoring a computer account from the recycle bin no longer fails if
    there are more than one object with the same name in the recycle bin.
    Now it uses the object that was changed last using the property
    whenChanged (issue dsccommunity#271).
- Changes to xADGroup
  - Restoring a group from the recycle bin no longer fails if there are
    more than one object with the same name in the recycle bin. Now it
    uses the object that was changed last using the property whenChanged
    (issue dsccommunity#271).
- Changes to xADOrganizationalUnit
  - Restoring a organization unit from the recycle bin no longer fails if
    there are more than one object with the same name in the recycle bin.
    Now it uses the object that was changed last using the property whenChanged
    (issue dsccommunity#271).
- Changes to xADUser
  - Restoring a user from the recycle bin no longer fails if there are
    more than one object with the same name in the recycle bin. Now it
    uses the object that was changed last using the property whenChanged
    (issue dsccommunity#271).
johlju added a commit to johlju/ActiveDirectoryDsc that referenced this issue May 11, 2019
- Changes to xADComputer
  - Restoring a computer account from the recycle bin no longer fails if
    there are more than one object with the same name in the recycle bin.
    Now it uses the object that was changed last using the property
    whenChanged (issue dsccommunity#271).
- Changes to xADGroup
  - Restoring a group from the recycle bin no longer fails if there are
    more than one object with the same name in the recycle bin. Now it
    uses the object that was changed last using the property whenChanged
    (issue dsccommunity#271).
- Changes to xADOrganizationalUnit
  - Restoring a organization unit from the recycle bin no longer fails if
    there are more than one object with the same name in the recycle bin.
    Now it uses the object that was changed last using the property whenChanged
    (issue dsccommunity#271).
- Changes to xADUser
  - Restoring a user from the recycle bin no longer fails if there are
    more than one object with the same name in the recycle bin. Now it
    uses the object that was changed last using the property whenChanged
    (issue dsccommunity#271).
johlju added a commit that referenced this issue May 14, 2019
- Changes to xADComputer
  - Restoring a computer account from the recycle bin no longer fails if there
    is more than one object with the same name in the recycle bin. Now it uses
    the object that was changed last using the property whenChanged (issue #271).
- Changes to xADGroup
  - Restoring a group from the recycle bin no longer fails if there is more than
    one object with the same name in the recycle bin. Now it uses the object
    that was changed last using the property whenChanged (issue #271).
- Changes to xADOrganizationalUnit
  - Restoring an organizational unit from the recycle bin no longer fails if there
    is more than one object with the same name in the recycle bin. Now it uses
    the object that was changed last using the property whenChanged (issue #271).
- Changes to xADUser
  - Restoring a user from the recycle bin no longer fails if there is more than
    one object with the same name in the recycle bin. Now it uses the object
    that was changed last using the property whenChanged (issue #271).
@kwirkykat kwirkykat removed the in progress The issue is being actively worked on by someone. label May 14, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants