Как правильно создать / обновить общую папку через EWS, используя олицетворение администратора? - PullRequest
0 голосов
/ 26 сентября 2018

Я не могу создать какую-либо общедоступную папку в случае, когда я установил правильное разрешение (через WebUI) для этого пользователя (в моем случае admin).

Но когда я пытаюсь обновить 'EffectiveRights' публичной папки додобавить уровень разрешений для этого пользователя, я не могу это сделать.Какой запрос мне нужно отправить, чтобы обновить уровень разрешений пользователей в общей папке или добавить надлежащие «EffectiveRights» в эту общую папку?

Пример запроса:

POST outlook.office365.com/EWS/Exchange.asmx

Content-Type:text/xml; charset=utf-8
Accept:text/xml;       charset=utf-8

BODY

<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" 
    xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
        <soap:Header>
        <t:RequestServerVersion Version="Exchange2013_SP1" />
            <t:ExchangeImpersonation>
                <t:ConnectingSID>
                    <t:PrimarySmtpAddress>test@test_test.onmicrosoft.com</t:PrimarySmtpAddress>
                </t:ConnectingSID>
            </t:ExchangeImpersonation>
        </soap:Header>
    <soap:Body>
    <UpdateFolder xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
                  xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <FolderChanges>
        <t:FolderChange>
          <t:DistinguishedFolderId Id="publicfoldersroot" />
          <t:Updates>
            <t:SetFolderField>
              <t:FieldURI FieldURI="folder:EffectiveRights"/>
              <t:Folder>
                <t:EffectiveRights>
                  <t:CreateAssociated>false</t:CreateAssociated>
                  <t:CreateContents>true</t:CreateContents>
                  <t:CreateHierarchy>false</t:CreateHierarchy>
                  <t:Delete>false</t:Delete>
                  <t:Modify>false</t:Modify>
                  <t:Read>true</t:Read>
                </t:EffectiveRights>
              </t:Folder>
            </t:SetFolderField>
          </t:Updates>
        </t:FolderChange>
      </FolderChanges>
    </UpdateFolder>
  </soap:Body>
  </soap:Envelope>   

, и ответ:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="1164" MinorBuildNumber="25" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    </s:Header>
    <s:Body>
        <m:UpdateFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ResponseMessages>
                <m:UpdateFolderResponseMessage ResponseClass="Error">
                    <m:MessageText>Set action is invalid for property.</m:MessageText>
                    <m:ResponseCode>ErrorInvalidPropertySet</m:ResponseCode>
                    <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                    <m:MessageXml>
                        <t:FieldURI FieldURI="folder:EffectiveRights"/>
                    </m:MessageXml>
                    <m:Folders/>
                </m:UpdateFolderResponseMessage>
            </m:ResponseMessages>
        </m:UpdateFolderResponse>
    </s:Body>
</s:Envelope>

еще один пример:

POST outlook.office365.com/EWS/Exchange.asmx

Content-Type:text/xml; charset=utf-8
Accept:text/xml;       charset=utf-8

BODY

<?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="Exchange2013_SP1" />
            <t:ExchangeImpersonation>
                <t:ConnectingSID>
                    <t:PrimarySmtpAddress>test@test_test.onmicrosoft.com</t:PrimarySmtpAddress>
                </t:ConnectingSID>
            </t:ExchangeImpersonation>
  </soap:Header>
  <soap:Body>
    <m:UpdateFolder>
      <m:FolderChanges>
        <t:FolderChange>
          <t:FolderId Id="AAEuAAAAAAAaRHOQqmYRzZvIAKoAL8RaAwCOXNGsJPKoS5iTrqfBNvbzAACDSr4rAAA=" />
          <t:Updates>
            <t:SetFolderField>
              <t:FieldURI FieldURI="folder:PermissionSet" />
              <t:Folder>
                <t:PermissionSet>
                  <t:Permissions>
                    <t:Permission>
                      <t:UserId>
                        <t:PrimarySmtpAddress>test@test_test.onmicrosoft.com</t:PrimarySmtpAddress>
                      </t:UserId>
                      <t:PermissionLevel>Editor</t:PermissionLevel>
                    </t:Permission>
                  </t:Permissions>
                </t:PermissionSet>
              </t:Folder>
            </t:SetFolderField>
          </t:Updates>
        </t:FolderChange>
      </m:FolderChanges>
    </m:UpdateFolder>
  </soap:Body>
</soap:Envelope>

и ответ:

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:ServerVersionInfo MajorVersion="15" MinorVersion="20" MajorBuildNumber="1143" MinorBuildNumber="18" Version="V2018_01_08" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
    </s:Header>
    <s:Body>
        <m:UpdateFolderResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
            <m:ResponseMessages>
                <m:UpdateFolderResponseMessage ResponseClass="Error">
                    <m:MessageText>Access is denied. Check credentials and try again., Underlying MAPI stream threw exception</m:MessageText>
                    <m:ResponseCode>ErrorAccessDenied</m:ResponseCode>
                    <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
                    <m:Folders/>
                </m:UpdateFolderResponseMessage>
            </m:ResponseMessages>
        </m:UpdateFolderResponse>
    </s:Body>
</s:Envelope>

1 Ответ

0 голосов
/ 27 сентября 2018

Поскольку вы пытаетесь создать папки в publicfoldersroot, ни один пользователь по умолчанию не имеет права делать это (это предотвращает путаницу в корне публичной папки).Поэтому, если вы хотите, чтобы ваш пользователь test@test_test.onmicrosoft.com, вам нужно было бы сначала предоставить им права сделать это в корневой папке, используя EAC или Add-PublicFolderclientPermissions.Я бы посоветовал вам сначала создать папку в Root с помощью EAC, а затем получить свой код для создания дочерних папок, которые с точки зрения разработки легче очистить, когда вам нужно удалить все и протестировать снова, а затем попытаться очиститьвся корневая иерархия каждый раз.

Также будет работать только ваш второй пример, потому что EffectiveRights - это свойство вычисления, поэтому его нельзя обновить, все, что вы можете сделать, - это обновить базовый DACL папки, которая вам нужназапрос выполняется

...