简体   繁体   English

Office 365 EWS-GetUserAvailability ID 为 null

[英]Office 365 EWS - GetUserAvailability ID is null

I am connecting to Exchange on 365 using EWS and using the GetUserAvailability method on the ExchangeService object to retrieve a collection of calendar items for a number of users (no more that 30).我正在使用 EWS 连接到 Exchange 365,并使用 ExchangeService object 上的 GetUserAvailability 方法来检索多个用户(不超过 30 个)的日历项目集合。

My user that I am using to connect to EWS has impersonation rights and everything is working with the exception of one thing.我用来连接到 EWS 的用户具有模拟权限,除了一件事外,一切正常。

When I loop through the AttendeesAvailability collection, and then through each CalendarEvent within its CalendarEvents collection, I am able to see the Details object and access things like the Subject, Location, IsPrivate, etc...当我遍历 AttendeesAvailability 集合,然后遍历其 CalendarEvents 集合中的每个 CalendarEvent 时,我能够看到详细信息 object 并访问主题、位置、IsPrivate 等内容...

The problem I have, is that the Details.StoreId is always null.我遇到的问题是,Details.StoreId 始终是 null。

I have two 365 Exchange environments, our and a client's.我有两个 365 Exchange 环境,我们的和客户的。 When I try and access the StoreId on ours, it works absolutely fine and has the unique ID as expected.当我尝试访问我们的 StoreId 时,它工作得非常好,并且具有预期的唯一 ID。 When I run the same come on the client's instance, it is null;当我在客户端实例上运行相同的命令时,它是 null; but all the other properties are populated for the Details object.但为详细信息 object 填充所有其他属性。

This lead me to believe that it was a permissions issue for the service user within Exchange.这让我相信这是 Exchange 中服务用户的权限问题。 So, I have slowly raised the permissions levels, hoping to hit the sweet spot, but nothing.所以,我慢慢地提高了权限级别,希望能达到最佳状态,但一无所获。 The user is now an Exchange Admin (which I believe should have blanket access to anything and everything within the Exchange environment - including calendar items for each person's mailbox).用户现在是 Exchange 管理员(我认为应该可以全面访问 Exchange 环境中的所有内容 - 包括每个人邮箱的日历项目)。 Still not joy.还是不开心。

So, is it a configuration issue with the Exchange setup?那么,这是 Exchange 设置的配置问题吗?

It is worth noting that all the other functionality that my application has, works perfect.值得注意的是,我的应用程序具有的所有其他功能都运行良好。 It is just this ID that I am missing.我缺少的只是这个ID。

I am at a loss on this one.我对此一无所知。 If it wasn't for the fact that I have shaved my head due to the lock down, I would be pulling my hair out right about now.如果不是因为锁定我剃了光头,我现在就会把头发拉出来。

Any help or suggestions would be greatly appreciated.任何帮助或建议将不胜感激。

Cheers干杯

UPDATE 1更新 1

So, I have found that if I perform the same process on the service account that I am authenticating with, I get the StoreId back.所以,我发现如果我对我正在验证的服务帐户执行相同的过程,我会得到 StoreId。 This account was created after the migration from on-prem to O365 (which may mean nothing).此帐户是在从本地迁移到 O365 后创建的(这可能没有任何意义)。 I am in the process of getting access to another account that has been created since the migration to see if it works for that one as well.我正在访问自迁移以来创建的另一个帐户,以查看它是否也适用于该帐户。 This will help me identify if the issue is likely to be with the migrated mailboxes only or with any mailbox apart from the account used to authenticate.这将帮助我确定问题是否可能仅与迁移的邮箱有关,或者与用于身份验证的帐户以外的任何邮箱有关。 I will update soon...我会尽快更新...

UPDATE 2更新 2

I have tested against a new account.我已经针对一个新帐户进行了测试。 I set the default permissions on the new account's calendar to Reviewer (even tried Owner and Anonymous just for a sanity check).我将新帐户日历上的默认权限设置为 Reviewer(甚至尝试 Owner 和 Anonymous 只是为了进行健全性检查)。 When I authenticate using the service account, I don't get the StoreId.当我使用服务帐户进行身份验证时,我没有得到 StoreId。 When I authenticate using the new test account, I do get the StoreId.当我使用新的测试帐户进行身份验证时,我确实获得了 StoreId。

This leads me to believe that it is a permissions issue.这让我相信这是一个权限问题。 It's now a case of finding out what that magic permissions is.现在是找出神奇权限是什么的一个案例。 It still eludes me as to why it is only the ID that I don't get back.我仍然无法理解为什么只有我没有找回的 ID。

Still open to any suggestions.仍然愿意接受任何建议。

UPDATE 3更新 3

It looks like it may be something different between build versions on EWS.看起来 EWS 上的构建版本之间可能有所不同。

The version that works is reporting a server version of 15.20.3021.030.有效的版本报告服务器版本为 15.20.3021.030。 The version that does not work is version 15.20.3045.019.不起作用的版本是版本 15.20.3045.019。

So, it's been a while, but Microsoft have now fixed the issue and the existing code is now working fine.所以,已经有一段时间了,但微软现在已经解决了这个问题,现有的代码现在可以正常工作了。

I can also confirm that this work when using OAuth as well.在使用 OAuth 时,我也可以确认这项工作。

The problem is probably related to not having sufficient rights from the account you use for the Exchange Service authentication to the target account.该问题可能与您用于 Exchange 服务身份验证的帐户对目标帐户没有足够的权限有关。 Use the command below to give rights and try again.使用以下命令授予权限,然后重试。

Add-MailboxFolderPermission -Identity User@domain.com:\Calendar -User serviceceaccount@domain.com -AccessRights Reviewer

This is a very annoying issue, I have opened an incident with MS in the past, but got the disappointing answer that this won't change soon.这是一个非常烦人的问题,我过去曾与 MS 发生过事件,但得到的答案令人失望,这不会很快改变。

Below is the PS code to set rights to all users, rooms, resources, regardless of culture (language) and name of the calendar folder.下面是为所有用户、房间、资源设置权限的 PS 代码,不考虑文化(语言)和日历文件夹的名称。

Param(
     [parameter(position=0,Mandatory=$true)][string] $serviceaccount,
     [parameter(position=1,Mandatory=$true)][string] $mailboxtype
)

$acl = "Reviewer"

if ($mailboxtype -eq "All") {
    $mailboxes = Get-Mailbox | Where {$_.RecipientTypeDetails -eq "UserMailbox" -or $_.RecipientTypeDetails -eq "RoomMailbox" -or $_.RecipientTypeDetails -eq "EquipmentMailbox"} | Select -expand PrimarySmtpAddress | Select -expand Address | Where {$_ -NotLike "Administrator@*"}
}
elseif ($mailboxtype -eq "Users") {
    $mailboxes = Get-Mailbox | Where {$_.RecipientTypeDetails -eq "UserMailbox"} | Select -expand PrimarySmtpAddress | Select -expand Address | Where {$_ -NotLike "Administrator@*"}
}
elseif ($mailboxtype -eq "Resources") {
    $mailboxes = Get-Mailbox | Where {$_.RecipientTypeDetails -eq "RoomMailbox" -or $_.RecipientTypeDetails -eq "EquipmentMailbox"} | Select -expand PrimarySmtpAddress | Select -expand Address
}
else {
"Error specifying target mailbox type. Choose one of: 'All', 'Users' or 'Resources'.`n
'All' - UserMailbox, RoomMailbox, EquipmentMailbox.`n
'Users' - UserMailbox.`n
'Resources' - RoomMailbox, EquipmentMailbox."
}

foreach ($mbx in $mailboxes)
{
    $calName = Get-MailboxFolderStatistics -Identity $mbx -FolderScope Calendar | Where-Object { $_.FolderType -eq 'Calendar'} | Select-Object Name, FolderId #-ErrorAction Stop
    #echo "${mbx}:\$($calName.Name)"
    Add-MailboxFolderPermission -Identity ${mbx}:\$($calName.Name) -User $serviceaccount -AccessRights $acl | Select-Object Identity, FolderName, User, AccessRights
}

Save as PS script, call with two params: serviceaccount & mailboxtype另存为 PS 脚本,使用两个参数调用:serviceaccount & 邮箱类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM