Reputation: 390
I'm trying to use CreateItem to create a CalendarItem for a Mailbox belonging to a user other than the one I'm connected as. The user I am connecting as does not have a Mailbox.
Below is my xml
<CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
SendMeetingInvitations="SendToAllAndSaveCopy" >
<SavedItemFolderId>
<t:DistinguishedFolderId Id="calendar">
<Mailbox>
<EmailAddress>user1@testhost</EmailAddress>
</Mailbox>
</t:DistinguishedFolderId>
</SavedItemFolderId>
<Items>
<t:CalendarItem xmlns="http://schemas.microsoft.com/exchange/services/2006/types">
<Subject>Test Calendar Entry</Subject>
<Body BodyType="Text">Test.</Body>
<ReminderIsSet>true</ReminderIsSet>
<ReminderMinutesBeforeStart>60</ReminderMinutesBeforeStart>
<Start>2012-01-20T09:00:00</Start>
<End>2012-01-20T17:00:00</End>
<IsAllDayEvent>false</IsAllDayEvent>
<Location>Test Location</Location>
</t:CalendarItem>
</Items>
</CreateItem>
After sending this to the server the reply I receive is:
[MessageText] => When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids.
[ResponseCode] => ErrorMissingEmailAddress
Additionally, I can successfully run this xml from an account with a mailbox (omitting the mailbox element) and it does create the Calendar item.
I've checked the user I'm logging in as does have full access to user1's mailbox.
I've tried specifying the UPN instead of the primary SMTP.
If I specify an invalid or non-primary email address, I get the expected errors, which indicates I am specifying the correct element.
Thanks in advance for any hints.
Upvotes: 1
Views: 1124
Reputation: 3859
An issue with impersonation, well if your on the 2007 Exchange Server, is that you don't have much control on the granularity of roles applied to the impersonating user. Exchange server 2010 addresses this with role based impersonation. You may want to look at phasing it in if you have a large user base.
I think the standard behavior is to create a service account which would have the impersonation rights on the groups/people your interested in. This approach minimizes the number of users who need to be granted the impersonation rights and also allows you to control the access as its all through your API
The other way Exchange allows you to get this behavior is through delegation of course that is only through the Outlook UI.
Upvotes: 0
Reputation: 36
You have to impersonate as other user before do any operation on the calendar item
Upvotes: 2