访问Exchange 2010 SP2中的另一个邮箱时(我获得了其文件夹的所有者权限,通过创建/修改/删除收件箱上的用户权限来检查OUT OUTOOK)。
现在,如果我通过EWS尝试相同的事情,我只会得到“访问被拒绝。检查凭据并重试。”。现在,我实际上使用与outlook相同的凭据(Windows Auth),使用以下代码:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
service.PreAuthenticate = true;
service.AutodiscoverUrl(<myUser_with_rights>);
FolderView view = new FolderView(50);
view.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
view.PropertySet.Add(FolderSchema.DisplayName);
SearchFilter searchFilter = new SearchFilter.IsGreaterThan(FolderSchema.TotalCount, 0);
view.Traversal = FolderTraversal.Shallow;
FolderId InboxId = new FolderId(WellKnownFolderName.MsgFolderRoot, <emailAddressOfOtherMailbox>);
findFolderResults = service.FindFolders(InboxId, view);
foreach (Microsoft.Exchange.WebServices.Data.Folder myFolder in findFolderResults.Folders)
{
myFolder.Load();
PropertySet propSet = new PropertySet(BasePropertySet.FirstClassProperties, FolderSchema.Permissions);
Microsoft.Exchange.WebServices.Data.Folder fo = Microsoft.Exchange.WebServices.Data.Folder.Bind(service, myFolder.Id, propSet);
fo.Permissions.Add(new UserId(<email>,<permission>));
fo.Update();//<-----Exception occurs
}
没有尝试更新哪个文件夹/节点更新,它总是失败。读取权限的工作正好。
有没有人有想法?