我试图通过利用Powershell中的.Net ADAL库,在联邦域中更新Azure用户的UPN (加载了Azure )。我相当肯定在Azure中和PS中正确配置了所有内容,因为如果我发出一个命令来更新usageLocation属性,它就能工作(为简洁起见而剪裁):
$UPN="user@mytenant.edu"
$Body=@{UsageLocation="JP"} | ConvertTo-JSON
$Result=Invoke-RestMethod -Method PATCH -Uri "https://graph.microsoft.com/v1.0/users/${UPN}" -Headers @{Authorization=$authenticationResult.CreateAuthorizationHeader()} -ContentType "application/json" -Body $Body
$user=Invoke-RestMethod -Method GET -Uri "https://graph.microsoft.com/v1.0/users/${UPN}?`$select=usageLocation" -Headers @{Authorization=$authenticationResult.CreateAuthorizationHeader()} -ContentType "application/json"
$user.usageLocation
JP
但是,如果我试图将UPN更新为非联邦域(因此我不会与http://blogs.perficient.com/microsoft/2013/03/changing-upn-for-office-365-account-between-two-sso-domains/中描述的问题发生冲突),我将得到一个内部服务器错误(500):
$UPN="user@mytenant.edu"
$Body=@{userPrincipalName="user@tenant.onmicrosoft.com"} | ConvertTo-JSON
$Result=Invoke-RestMethod -Method PATCH -Uri "https://graph.microsoft.com/v1.0/users/${UPN}" -Headers @{Authorization=$authenticationResult.CreateAuthorizationHeader()} -ContentType "application/json" -Body $Body
Invoke-RestMethod : The remote server returned an error: (500) Internal Server Error.
我尝试过许多不同的变体,包括检索Azure AD GUID,并在补丁命令中使用它而不是UPN,并使用旧的Azure AD图(它返回相同的500错误)。我可以使用O365 Powershell命令进行更改:
Set-MsolUserPrincipalName -UserPrincipalName $UPN -NewUserPrincipalName $newUPN
但我似乎不能让它通过MS图形工作。图的文档意味着可以像其他属性一样更新UPN (c.v )。例如,update )。我想知道,如果因为UPN是一个关键,也许这使得更新不工作?我也不认为这是一个权限问题,那些通常会抛出“不足以完成操作的特权”。这不是我看到的。
谢谢!
UPDATE1:以下是今早重新尝试的错误对象所能找到的所有内容:
{
"error": {
"code": "Service_InternalServerError",
"message": "Encountered an internal server error.",
"innerError": {
"request-id": "cbb08d3c-1143-4d0b-8722-5230b00bd00f",
"date": "2016-02-15T16:48:15"
}
}
}
发布于 2016-02-16 18:06:22
我看了一下跟踪,我将在我们这边为500错误提交一个bug (我们在这里肯定可以做得更好)。根据跟踪,如果要通过将用户从联邦域重命名为云托管域来更新用户,则必须提供/设置密码作为请求的一部分(使用passwordProfile复杂类型)。这就是根据日志请求失败的原因。如果这能解决你的问题,请告诉我们。
https://stackoverflow.com/questions/35232113
复制相似问题