【问题标题】:Unable to update the specified properties for on-premises mastered Directory Sync objects - Updating users manager attribute in azure ad无法更新本地主控目录同步对象的指定属性 - 更新 azure ad 中的用户管理器属性
【发布时间】:2020-04-22 02:05:18
【问题描述】:

在彻底寻找解决方案后,我希望得到一些指导。

我希望更新填充在本地广告中的用户管理器属性,但据我所知 azure/365 并未复制此属性。

所以我必须使用下面的代码手动更改它们;

Set-AzureADUserManager -ObjectId "usersid" -RefObjectId "managersid"

一旦我运行它就会失败并出现以下错误;

Code: Request_BadRequest
Message: Unable to update the specified properties for on-premises mastered Directory Sync objects or objects currently undergoing migration.
RequestId: 
HttpStatusCode: BadRequest
HttpStatusDescription: Bad Request
HttpResponseStatus: Completed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : NotSpecified: (:) [Set-AzureADUserManager], ApiException
   + FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.SetUserManager

我不确定这是什么问题,因为用户管理器在 Azure 中与 Windows 广告作为源同步。

谢谢。

【问题讨论】:

    标签: powershell active-directory azure-active-directory office365 windows-server-2012


    【解决方案1】:

    根据the docs Manager 属性是同步的。

    这里的Get 和Set cmdlet 都需要DistinguishedName、ObjectGUID、ObjectSID 或SamAccountName 用于-Identity 和-Manager 参数。

    你应该可以做到:

    # set the manager property for the user
    Get-ADUser -Identity "<THE USER>" | Set-ADUser -Manager "<THE MANAGER>"
    

    之后,您可以使用以下方式强制执行 AD Sync:

    $server  = 'YourAzureConnectServer'
    $cred    = Get-Credential -Message 'Please enter user name and password for AD Sync'
    $session = New-PSSession -ComputerName $server -Credential $cred
    
    Invoke-Command -Session $session {
        if (Get-ADSyncConnectorRunStatus) {
            Write-Warning "A sync is already in progress. Please try again later."
        }
        else {
            Write-Host "Initializing Azure AD Delta Sync..." -ForegroundColor Yellow
            try {
                Start-ADSyncSyncCycle -PolicyType Delta -ErrorAction Stop
    
                Write-Host "Waiting for Sync to start.."
                # give the Sync Connector 10 seconds time to start-up
                Start-Sleep -Seconds 10
    
                Write-Host "Waiting for Sync to finish.."
                While(Get-ADSyncConnectorRunStatus) {
                    Write-Host "." -NoNewline
                    Start-Sleep -Seconds 5
                }
                Write-Host
                Write-Host "Azure AD Sync has finished." -ForegroundColor Green
            }
            catch {
                Write-Error $_
            }
        }
    }
    
    Remove-PSSession $session
    

    您还可以使用Start-ADSyncSyncCycle -PolicyType Initial强制进行完整的属性同步

    【讨论】:

    • 您确定经理应该同步是正确的,但在天蓝色广告中,经理字段为空白;使用上面的代码不会更新该字段,它所做的只是更新已经填充的活动目录。运行同步不会向 azure 广告添加任何新信息。我正在寻找解决方案,或了解失败的原因,以解决此问题。
    • @bob500000 我明白了。也许您应该查看this 以检查 Manager 属性是否已同步。如果您确定它是,或者如果您刚刚启用它,请使用 PolicyType Initial。希望有帮助
    • 是的,我在上面使用了它,但是 adsync 不允许您使用向导选择 manager 作为属性,因此我正在寻找 ps。但是据我了解,似乎存在写入问题,并且我一直在使用的 ps 正在报告上述错误。 - 顺便谢谢你的帮助。
    【解决方案2】:

    似乎我需要将同步规则添加到同步规则编辑器 - 我遵循以下 - [Link] (blog.kloud.com.au/2016/11/14/...) - 我添加了一个同步规则在 ad 和 azure 之间再回来,这似乎已经解决了问题,不需要 ps 脚本。 - 再次感谢@theo 的帮助。 ——

    【讨论】:

    • 你好,你可以接受你的回答,它可以帮助别人,谢谢。
    猜你喜欢
    • 1970-01-01
    • 2019-12-10
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多