枚举您可以使用EWS托管API访问的共享邮箱名称 [英] Enumerating shared mailbox names you are able to access using EWS Managed API

查看:116
本文介绍了枚举您可以使用EWS托管API访问的共享邮箱名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了一个共享邮箱,并且可以访问它及其子文件夹:

I set up a shared mailbox and can access it and its sub-folders:

var folderId = new FolderId(WellKnownFolderName.MsgFolderRoot, "shared.mailbox@domain.local");
var folders = client.FindFolders(folderId, new FolderView(Int32.MaxValue));

为此,我需要知道共享邮箱的名称-在此示例中,共享邮箱的名称为 shared.mailbox@domain.local .有什么方法可以枚举我可以访问的所有共享邮箱名称?我曾尝试过在线搜索,但找不到解决方案.

To do this I need to know the name of the shared mailbox - in this example, the name of the shared mailbox is shared.mailbox@domain.local. Is there any way to enumerate through all of the shared mailbox names I am able to access? I have tried searching online but I could not find a solution.

推荐答案

例如,当您从Exchange连接到Office 365帐户并加入一个组时,您会看到该组的共享邮箱.然后,当您在线(而不是在Exchange中)浏览到Office 365邮箱时,您也会在那里看到该组,

when you for example connect to an Office 365 account from Exchange and join a group, you see the shared mailbox of that group. When you then browse to your Office 365 mailbox online and not in Exchange, you see that group there as well,

如果您谈论的是一个Office365组,则可以通过git hub https://github.com/OfficeDev/ews-managed-api 例如

If its a Office365 Group your talking about you can access these via the GetUserUnifiedGroups in the latest version of the Managed API from git hub https://github.com/OfficeDev/ews-managed-api eg

        RequestedUnifiedGroupsSet Group = new RequestedUnifiedGroupsSet();
        Group.FilterType = UnifiedGroupsFilterType.All;
        Group.SortDirection = SortDirection.Ascending;
        Group.SortType = UnifiedGroupsSortType.DisplayName;
        List<RequestedUnifiedGroupsSet> reqG = new List<RequestedUnifiedGroupsSet>();
        reqG.Add(Group);
        Collection<UnifiedGroupsSet> ugGroupSet = service.GetUserUnifiedGroups(reqG,"jcool@domain.com");
        foreach (UnifiedGroupsSet ugset in ugGroupSet)
        {
            foreach (UnifiedGroup ugGroup in ugset.Groups)
            {
                Console.WriteLine(ugGroup.SMTPAddress);
            }
        } 

在其中启用了自动映射的位置被授予访问权限的邮箱(这些邮箱是Outlook会自动映射到配置文件中的邮箱),例如Add-MailboxPermission -AutoMapping可以使用自动发现来找到,例如

Mailboxes that where granted access to where Auto-mapping is enabled (these are the Mailboxes that Outlook will Auto-map into a profile) eg Add-MailboxPermission -AutoMapping can be discovered using Autodiscover eg

AutodiscoverService adAutoDiscoverService = new AutodiscoverService(ExchangeVersion.Exchange2013_SP1);
adAutoDiscoverService.Credentials = new NetworkCredential("user@domain.com", "pass");
adAutoDiscoverService.EnableScpLookup = false;
adAutoDiscoverService.RedirectionUrlValidationCallback = adAutoDiscoCallBack;
adAutoDiscoverService.PreAuthenticate = true;
adAutoDiscoverService.KeepAlive = false;




GetUserSettingsResponse gsp = adAutoDiscoverService.GetUserSettings("user@domain.com", UserSettingName.AlternateMailboxes);
Object Mailboxes = null;
if (gsp.Settings.TryGetValue(UserSettingName.AlternateMailboxes, out Mailboxes))
{
    foreach (AlternateMailbox Mailbox in ((AlternateMailboxCollection)Mailboxes).Entries) 
    {
        Console.WriteLine(Mailbox.SmtpAddress);
    }
}

但是,您刚刚将权限添加到邮箱或文件夹的邮箱,则无法了解彼此,然后枚举每个邮箱DACL并进行检查.

However Mailboxes where you have just added the rights to a Mailbox or a Folder there is no way of knowing this other then enumerating each of the Mailboxes DACL and check that.

这篇关于枚举您可以使用EWS托管API访问的共享邮箱名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆