Office365 Groups (or unified\modern groups) is a new feature the was introduced in Office365 that Exchange Online is an active participant in by providing the Email/Conversation and calendar portions of this feature. Recently there was a new unified REST API released in preview https://msdn.microsoft.com/en-us/office/office365/howto/office-365-unified-api-overview that I'll look at another day but with this post I want to look at just accessing the Exchange portion of the unified Groups using EWS and also we will take a look at how the config is stored in the mailbox.
Accessing using the EWS Managed API
If your following the changes to the EWS Managed API open source repository https://github.com/OfficeDev/ews-managed-api support for reading the available Unified groups a Mailbox is a member of was added in April. This is done using the yet to be documented GetUserUnifiedGroups EWS operation. So if you have a version of the Managed API compiled from this source that includes these updates (there is a sample one from one of my other post here ) . You can then use the following code to get all the Unified Groups a Mailbox is a member of
or in PowerShell
(Note as I'm writing this I think there is a bug in this operation when using the Mailbox overload)
Once you have the SMTPAddress of the Group you can just Bind to the Group using a normal Folder bind eg either the Inbox (for conversations) or the Calendar
For those people interested in the how this get implemented in your mailbox here's what it looks like. In the Mailbox Non_IPM_Subtree there is a folder called MailboxAssociations this gets created eg
Then in the normal Messages collection of this folder when you subscribe to a group (or are made a member of one) an item of type IPM.MailboxAssociation.Group will be created. On this Item's extended properties get set with the relevant information for the group eg
So if you have an older version of the Managed API where you don't have access to the newer updates you can still get the Group memberships for a mailbox by accessing these IPM.MailboxAssociation.Group objects and then reading the extended properties. Eg first to bind to the MailboxAssociations use the following extended property which will give you the HexId of the folder which you can then convert to an EWSId to bind to the folder.
Once you bind to the MailboxAssoications Folder you can then just use a FindItem op with a search filter to limit the results to just the Group associations. Then pull the extended property for the LegacyDN of the MailboxAssoication then you just need to resolve that to the SMTPAddress eg
So as you can see it's a little more complicated this way so try to use the other op where you can.