0

I have been tasked with writing a .NET application that has to have access to a users exchange calendar. This application will only be accessed from the local network and I need to have to automatically use the current domain users credentials to access exchange.

I have the following code but I get an error saying "The account does not have permission to impersonate the requested user."

ExchangeService service = new ExchangeService();
service.UseDefaultCredentials = true;
string exchange = "exchangeWSURL";
service.Url = new Uri(exchange);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.PrincipalName, userid);
service.PreAuthenticate = true;
CalendarView cal = new CalendarView(startDate, startDate.AddDays(7));
FindItemsResults<Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, cal);

It looks like I am doing something wrong. I was hoping to now have to turn on impersonation for all users on the domain.

Any help would be wonderful.

Joe Smith
  • 101
  • 1
  • 2
  • 4

2 Answers2

0

This article provides what you seem to be looking for. Take note of the paragraph on "Impersonation". This seems to suit your needs perfectly.

ASP.NET and Exchange tips and samples

Ian Atkin
  • 6,302
  • 2
  • 17
  • 24
0

Copied from MSDN:

You must configure the Exchange server to allow impersonation before your application can use impersonation. For more information, see Configuring Exchange Impersonation (Exchange Web Services).

https://msdn.microsoft.com/en-us/library/dd633680(v=exchg.80).aspx
https://msdn.microsoft.com/en-us/library/bb204095(exchg.140).aspx

Björn
  • 3,098
  • 2
  • 26
  • 40