exchange-server - EWS:InvalidOperationException / ServiceResponseException
问题描述
我有一个 EWS 同步器,在我的公司进行了一些撤消操作后,该同步器已停止工作。它无法编辑或更新其他员工的邮件,并说缺少日历的特权/权利。它在 2 周前工作,代码没有任何变化,我检查并查看 SID 已更改,但我更新了它,仍然给我缺少权限错误。我没有写这个,但我负责维护这个同步器程序,所以如果我在黑暗中听起来有点,请原谅。
服务响应异常:
else if (ex.InnerException is ServiceResponseException)
{
if (ex.InnerException.Message.ValueIn("The SMTP address has no mailbox associated with it.", "The specified folder could not be found in the store."))
{
a.ExchangeSyncronizationSettings.HasCalendarEditorPermission = false;
a.ExchangeSyncronizationSettings.Save(conn);
Console.WriteLine("Rettigheder til kalender mangler for " + a.Initials);
permissionEx.Add(a.Initials);
}
无效操作异常:
} catch(Exception ex) {
if(ex.InnerException != null) {
if(ex.InnerException is InvalidOperationException) {
if(ex.InnerException.Message == "Agent has not assigned editor permissions") {
a.ExchangeSyncronizationSettings.HasCalendarEditorPermission = false;
a.ExchangeSyncronizationSettings.Save(conn);
Console.WriteLine("Rettigheder til kalender mangler for " + a.Initials);
permissionEx.Add(a.Initials);
} else
exceptions.Add(ex.InnerException);
HasCalendarEditorPermissions:
private bool HasCalendarEditorPermissions(Folder calendar, string userSID) {
if(calendar == null)
throw new ArgumentNullException("calendar");
if(calendar.GetLoadedPropertyDefinitions().Contains(FolderSchema.Permissions))
SendExchangeRequest(() => calendar.Load(new PropertySet(FolderSchema.Permissions)));
return calendar.Permissions.Any(p => p.UserId.SID == userSID &&
p.DisplayPermissionLevel == FolderPermissionLevel.Editor);
}
编辑:
private Folder GetAgentCalendar(ExchangeService service, SAFEAgent agent) {
string username = agent.EmailAddress;
var calendar = SendExchangeRequest(() => Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, username)));
// if(!HasCalendarEditorPermissions(calendar, SC01_SID))
// throw new InvalidOperationException("Agent has not assigned editor permissions");
agent.ExchangeSyncronizationSettings.HasCalendarEditorPermission = true;
return calendar;
}
基本上,当我注释掉以下内容时,它会再次运行我的同步器,但是自从两周前工作以来发生了什么变化?
使程序再次运行的未注释代码
// if(!HasCalendarEditorPermissions(calendar, SC01_SID))
// throw new InvalidOperationException("Agent has not assigned editor permissions");
解决方案
推荐阅读
- ios - 如何删除统一ios键盘“完成”“取消”按钮
- javascript - 为什么在事件对象中使用extendedProps时FullCalendar事件解析仅限于Location和Description?
- django - razorpay 支付网关与 django 应用程序的集成
- sql - postgresql 中用于多个表连接的更新语句,我想为下面的更新语句优化更新,下面的语句需要很长时间
- xml - 如何使用单个标签解析 XML 响应
- javascript - 如何更改 billboard.js 中的线条颜色
- dialogflow-es - 未设置响应
- json - 如何为嵌套 JSON 对象创建接口
- hyperledger-fabric - 构建 Hyperledger Fabric v1.4.4 源代码时出错
- html - 如何在灯箱图像下添加按钮和段落而不被切断?