none
[E2007] [EWS] [C#] Updating Contact's Email using Delegated Account is throwing "Access is denied. Check credentials and try again" error RRS feed

  • Question

  • Exchange Version: 2007 SP2
    API Name: EWS
    API Version: 1.1
    IDE: Visual Studio
    Targeted features: UpdateItem using Delegation
    Scenario description: CreateItem is working. Updating email is causing this issue.

    Permission is given like below

     DelegateUser newDelegate = new DelegateUser(delegateEmailAddress);
                newDelegate.Permissions.ContactsFolderPermissionLevel = DelegateFolderPermissionLevel.Editor;
                newDelegate.Permissions.CalendarFolderPermissionLevel = DelegateFolderPermissionLevel.Editor;
                List<DelegateUser> delegatesToAdd = new List<DelegateUser>();
                delegatesToAdd.Add(newDelegate);

                Mailbox mailbox = new Mailbox(primaryEmailAddress);

                var results = service.AddDelegates(mailbox, MeetingRequestsDeliveryScope.DelegatesAndMe, delegatesToAdd);
                results.ToList().ForEach(result => {
                    if (result.ErrorCode == ServiceError.ErrorDelegateAlreadyExists)
                    {
                        Logger.Write("UpdateDelegates");
                        service.UpdateDelegates(mailbox, MeetingRequestsDeliveryScope.DelegatesAndMe, delegatesToAdd);
                    }
                    else
                    {
                        Logger.Write(result.ErrorDetails);
                    }
                });

     

    Request

    <EwsLogEntry EntryKind="EwsRequest" ThreadId="8" Timestamp="7/20/2011 6:23:47 PM">
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <t:RequestServerVersion Version="Exchange2007_SP1" />
          <t:TimeZoneContext>
            <t:TimeZoneDefinition Id="Pacific Standard Time" />
          </t:TimeZoneContext>
        </soap:Header>
        <soap:Body>
          <m:UpdateItem MessageDisposition="SaveOnly" ConflictResolution="AlwaysOverwrite">
            <m:ItemChanges>
              <t:ItemChange>
                <t:ItemId Id="AAMkAGQ4YTI5YzM3LTIxZWQtNDVlMC1iZjg2LTQ2MjAyMjRmYjM5ZgBGAAAAAABmbrYMs8hkQIbHwOSpdBZxBwDqbaZpQVrcTZOVQg8rq+ZqAKru7BRqAADqbaZpQVrcTZOVQg8rq+ZqAWn2xUXrAAA=" ChangeKey="EQAAABYAAADqbaZpQVrcTZOVQg8rq+ZqAWn2yDTM" />
                <t:Updates>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="contacts:GivenName" />
                    <t:Contact>
                      <t:GivenName>Delegate</t:GivenName>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="contacts:Surname" />
                    <t:Contact>
                      <t:Surname>2</t:Surname>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="contacts:FileAsMapping" />
                    <t:Contact>
                      <t:FileAsMapping>LastCommaFirst</t:FileAsMapping>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="contacts:DisplayName" />
                    <t:Contact>
                      <t:DisplayName>Delegate 2</t:DisplayName>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:FieldURI FieldURI="item:Subject" />
                    <t:Contact>
                      <t:Subject>Delegate 2</t:Subject>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:IndexedFieldURI FieldURI="contacts:EmailAddress" FieldIndex="EmailAddress1" />
                    <t:Contact>
                      <t:EmailAddresses>
                        <t:Entry Key="EmailAddress1">delegate2@gmail.com</t:Entry>
                      </t:EmailAddresses>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32901" PropertyType="Binary" />
                    <t:Contact>
                      <t:ExtendedProperty>
                        <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32901" PropertyType="Binary" />
                        <t:Value>AAAAAIErH6S+oxAZnW4A3QEPVAIAAAGQZABlAGwAZQBnAGEAdABlADIAQABnAG0AYQBpAGwALgBjAG8AbQAAAFMATQBUAFAAAABkAGUAbABlAGcAYQB0AGUAMgBAAGcAbQBhAGkAbAAuAGMAbwBtAAAA</t:Value>
                      </t:ExtendedProperty>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32898" PropertyType="String" />
                    <t:Contact>
                      <t:ExtendedProperty>
                        <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32898" PropertyType="String" />
                        <t:Value>SMTP</t:Value>
                      </t:ExtendedProperty>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32896" PropertyType="String" />
                    <t:Contact>
                      <t:ExtendedProperty>
                        <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32896" PropertyType="String" />
                        <t:Value>delegate2@gmail.com</t:Value>
                      </t:ExtendedProperty>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32900" PropertyType="String" />
                    <t:Contact>
                      <t:ExtendedProperty>
                        <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32900" PropertyType="String" />
                        <t:Value>delegate2@gmail.com</t:Value>
                      </t:ExtendedProperty>
                    </t:Contact>
                  </t:SetItemField>
                  <t:SetItemField>
                    <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32899" PropertyType="String" />
                    <t:Contact>
                      <t:ExtendedProperty>
                        <t:ExtendedFieldURI DistinguishedPropertySetId="Address" PropertyId="32899" PropertyType="String" />
                        <t:Value>delegate2@gmail.com</t:Value>
                      </t:ExtendedProperty>
                    </t:Contact>
                  </t:SetItemField>
                  <t:DeleteItemField>
                    <t:FieldURI FieldURI="contacts:MiddleName" />
                  </t:DeleteItemField>
                  <t:DeleteItemField>
                    <t:FieldURI FieldURI="contacts:JobTitle" />
                  </t:DeleteItemField>
                  <t:DeleteItemField>
                    <t:FieldURI FieldURI="contacts:CompanyName" />
                  </t:DeleteItemField>
                </t:Updates>
              </t:ItemChange>
            </m:ItemChanges>
          </m:UpdateItem>
        </soap:Body>
      </soap:Envelope>
    </EwsLogEntry>

     

    response

    sLogEntry EntryKind="EwsResponse" ThreadId="8" Timestamp="7/20/2011 6:23:48 PM">
      <?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Header>
          <t:ServerVersionInfo MajorVersion="8" MinorVersion="1" MajorBuildNumber="291" MinorBuildNumber="1" Version="Exchange2007_SP1" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" />
        </soap:Header>
        <soap:Body>
          <m:UpdateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
            <m:ResponseMessages>
              <m:UpdateItemResponseMessage ResponseClass="Error">
                <m:MessageText>Access is denied. Check credentials and try again.</m:MessageText>
                <m:ResponseCode>ErrorAccessDenied</m:ResponseCode>
                <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                <m:Items />
              </m:UpdateItemResponseMessage>
            </m:ResponseMessages>
          </m:UpdateItemResponse>
        </soap:Body>
      </soap:Envelope>
    </EwsLogEntry>





    Thursday, July 21, 2011 1:31 AM

Answers

  • I just have to add

    newDelegate.Permissions.InboxFolderPermissionLevel = DelegateFolderPermissionLevel.Editor
    • Marked as answer by Humblesticker Thursday, July 21, 2011 2:44 AM
    Thursday, July 21, 2011 2:43 AM