Reputation: 125
I am trying to setup Application Impersonation in Exchange 2010 to allow a .NET application the ability to read/update my organization's calendars.
So far, I have created a service account and a Role Assignment
New-ManagementRoleAssignment -Name:myServiceCalendar -Role:ApplicationImpersonation -User:myService
However, when I go to actually access the calendar of an account, I get an ErrorFolderNotFound
Here is the code that I am using for the test
var _testUserName = "[email protected]";
var _testUser = new WebCredentials(_testUserName, "Apass@wordForYou");
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
service.Credentials = _testUser;
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.AutodiscoverUrl(_testUserName);
var testCalendar = new Mailbox("[email protected]");
var folderCalendar = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, testCalendar)); // <-- FAILS HERE
var view = folderCalendar.FindItems(new ItemView(10));
Here is the error that I am getting
<Trace Tag="EwsResponse" Tid="10" Time="2015-08-07 19:26:11Z" Version="15.00.0847.030">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="1" MajorBuildNumber="218" MinorBuildNumber="6" Version="Exchange2010_SP
1" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/
types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:GetFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsof
t.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:GetFolderResponseMessage ResponseClass="Error">
<m:MessageText>The specified folder could not be found in the store.</m:MessageText>
<m:ResponseCode>ErrorFolderNotFound</m:ResponseCode>
<m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
<m:Folders />
</m:GetFolderResponseMessage>
</m:ResponseMessages>
</m:GetFolderResponse>
</s:Body>
</s:Envelope>
</Trace>
Here is the account I am trying to access
So my question is -- what am I missing? Did I setup the Role assignment incorrectly? Or do I need to do something different in the code?
Upvotes: 0
Views: 262