将 EntryId 转换为 EwsId 的问题,它给出 ImmutableId

问题描述 投票:0回答:1

我正在遵循教程并使用 EWS 或 GraphAPI 成功运行从 EntryId 到 EwsId 的转换(结果相同)。

但问题是,虽然我可以从 EntryId 转换为 RestId 并用 Graph 找到它,但从 EntryId 转换为 EwsId 然后 Binding 会给出错误 “此协议不支持 ImmutableIds”

$64decoded = [System.BitConverter]::ToString([System.Convert]::FromBase64String($ItemId)).Replace("-", "")
        write-host $64decoded
        $HexId = new-object Microsoft.Exchange.WebServices.Data.AlternateId([Microsoft.Exchange.WebServices.Data.IdFormat]::HexEntryId, $64decoded, $email)
        $Converted = $service.ConvertId($HexId, [Microsoft.Exchange.WebServices.Data.IdFormat]::EwsId)
        $idObject = new-object Microsoft.Exchange.WebServices.Data.ItemId($Converted.UniqueId)

或者使用库的 Graph:

$sourceID = ($sourceId -replace "\+","-") -replace "/","_"
$countToReplace = ($sourceID.ToCharArray() | ? {$_ -eq "="}).Count
$sourceID = $sourceID.TrimEnd("=") + $countToReplace

$body = @{
"inputIds"= @($sourceID)
"sourceIdType"= "entryId"
"targetIdType"= "$TargetFormat"
} | ConvertTo-Json

$ConvertResult =  Invoke-MgTranslateUserExchangeId -UserId $UserId -BodyParameter $body

结果肯定不是

EWSID
,它看起来像这样:

  1. 来源 ID:AAAAB2EAx##########################################gAAKDC/7wAAA==
  2. 目标 ID:AAkALg################################################i8zOVOAAAAAe9FwAA

我错过了什么?

谢谢你

exchangewebservices
1个回答
0
投票

从您在结果中发布的内容来看,以 AAkALg 开头的任何内容都是一个 immutableId https://learn.microsoft.com/en-us/graph/outlook-immutable-id“AAkALg”解码为告诉 Exchange 的标志这就是为什么每个请求都是相同的。您应该能够获取该 Id,然后将其转换为 ewsid,例如

{
    "inputIds": [
        "AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AdRBH-RjqME2dQLFCi6wg0AAIdd8qMwAA"
    ],
    "sourceIdType": "restImmutableEntryId",
    "targetIdType": "ewsId"
}

Invoke-MgTranslateUserExchangeId 中以前存在错误,因此我可能会尝试使用 Invoke-MgGraphRequest 来查看是否得到不同的结果,例如

    $ConvertRequest = @"
{
    "inputIds" : [
      "$FolderIdToConvert"
    ],
    "sourceIdType": "entryId",
    "targetIdType": "ewsId"
  }
"@

    $ConvertResult = Invoke-MgGraphRequest -Method POST -Uri https://graph.microsoft.com/v1.0/me/translateExchangeIds -Body $ConvertRequest

© www.soinside.com 2019 - 2024. All rights reserved.