我们开发了一个 SharePoint Web 部件,它通过为在 Office 365 上拥有邮箱的用户请求 Exchange OnPrem 2013 或 Exchange Online 来显示选定用户的日历项目。我们使用的代码如下:
// Impersonate the Search
ExchangeImpersonationType exchangeImpersonationType = new ExchangeImpersonationType();
ConnectingSIDType connectingSIDType = new ConnectingSIDType();
connectingSIDType.PrimarySmtpAddress = emailAddress;
exchangeImpersonationType.ConnectingSID = connectingSIDType;
exchangeServiceBinding.ExchangeImpersonation = exchangeImpersonationType;
// Create the Request
FindItemType findItemType = new FindItemType();
// Specified Transversal
findItemType.Traversal = ItemQueryTraversalType.Shallow;
// Specified ItemShape
ItemResponseShapeType itemResponseShapeType = new ItemResponseShapeType();
itemResponseShapeType.BaseShape = DefaultShapeNamesType.AllProperties;
findItemType.ItemShape = itemResponseShapeType;
// Specified ParentFolderIds
DistinguishedFolderIdType[] distinguishedFolderIdTypes = new DistinguishedFolderIdType[1];
distinguishedFolderIdTypes[0] = new DistinguishedFolderIdType();
distinguishedFolderIdTypes[0].Id = DistinguishedFolderIdNameType.calendar;
findItemType.ParentFolderIds = distinguishedFolderIdTypes;
// Specified Item
CalendarViewType calendarViewType = new CalendarViewType();
calendarViewType.StartDate = startDate;
calendarViewType.EndDate = endDate;
findItemType.Item = calendarViewType;
// Execute the Request
FindItemResponseType res = exchangeServiceBinding.FindItem(findItemType);
问题是当用户在 Exchange OnPrem 上没有邮箱时,该exchangeServiceBinding.FindItem
方法会在 3 到 5 秒后回复错误代码“UserHasNoMailbox”。
想象一下现在加载一个有 40 多个用户的页面,其中有 10 个用户在 Exchange Online 上拥有邮箱,在这种情况下我们至少损失了 30 秒。
有没有办法知道用户在 Exchange OnPrem 上是否有邮箱而不提出FindItem
请求?
谢谢。