Question

I'm trying to develop a application for syncing calendars & contacts to another system. The application is written in C#, but I don't understand how I can get all user's calendars and contacts, without knowing each one's credentials. The application shouldn't poll the information, but send it to my application like an event.

I already searched on MS sites, downloaded the 'Exchange 2013 101 Code Samples' ans successfully wrote a script which sends an e-mail to another user, but the authentification only worked with user credentials.

Is it possible to create a 'master' user who can read all calendars and contacts of a given list of users? Can ExchangeServer call my application and send the information (e.g. with SOAP), or do I have to poll?


UPDATE:

I created a user who has full permission on everything, but I don't know how to read the data from the server, because the calendar of the 'master' user is empty. When I visit OWA and choose to take an impersonate look into someone's calendar I can see the appointments.

Code for permissions:

Get-Mailboxdatabase | Add-ADPermission -AccessRights ExtendedRight -ExtendedRights Receive-As, Send-As -User "<SuperAccount>"

And this one shares the calendar:

Add-MailboxFolderPermission –Identity <MailboxFolderId>:\Calendar -AccessRight ReadItems -User <SuperAccount>

How can I get the calendar of a user with my master-user?

Was it helpful?

Solution 2

According to Jan Doggen's answer I found the solution in another StackOverflow thread, which can be found here: EWS: Access shared calendars

The answer from Seph was in Visual Basic, but it can be easily converted to C#:

using Microsoft.Exchange.WebServices.Data;

DateTime startTime = new DateTime(2013, 1, 1);
DateTime endTime = new DateTime(2013, 12, 31);

var cal = new FolderId(WellKnownFolderName.Calendar, new Mailbox("other user's email"));
var calendarView = new CalendarView(startTime.Date, endTime.Date.AddDays(1));

foreach (var appointmentItem in service.FindAppointments(cal, calendarView))
{
    Console.WriteLine(appointmentItem.Subject);
}

OTHER TIPS

The approach we use is that all users must share their calendars with a 'master' user, with full editing rights. This user has to be created in the domain of the server. Our code logs in to Exchange as that master user, and then it can access all calendars.

Another approach that I have no experience with is Impersonation. Exchange lets you act as an other user. You have to have impersonation rights under Windiows for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top