0

I want to get all users from Exchange server via EWS. I have realised that it is possible to do with FindPeople SOAP request as described in answer here

As it states in answer, this requires AddressListId. Thus I had to create GlobalAddressList on Exchange with PowerShell.

I have created GlobalAddressList following these instructions

I do not know how to add users into the GlobalAddressList?

Event that there is not users in the list I should be able to get the empty list? So I tried.

Here is is the request:

<?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>
        <RequestServerVersion Version="Exchange2013_SP1" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
      </soap:Header>
      <soap:Body>
        <FindPeople xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
          <IndexedPageItemView MaxEntriesReturned="100" Offset="0" BasePoint="Beginning" />
          <ParentFolderId>
            <AddressListId Id="someId" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
          </ParentFolderId>
        </FindPeople>
      </soap:Body>
    </soap:Envelope>

"someId" value above is GUID of GlobalAddressList that I created.

Here is the response with error that I get.

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<s:Envelope
    xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <s:Header>
        <Action s:mustUnderstand=\"1\"
            xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">*
        </Action>
    </s:Header>
    <s:Body>
        <s:Fault>
            <faultcode
                xmlns:a=\"http://schemas.microsoft.com/exchange/services/2006/types\">a:ErrorInternalServerError
            </faultcode>
            <faultstring xml:lang=\"en-US\">An internal server error occurred. The operation failed.</faultstring>
            <detail>
                <e:ResponseCode
                    xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">ErrorInternalServerError
                </e:ResponseCode>
                <e:Message
                    xmlns:e=\"http://schemas.microsoft.com/exchange/services/2006/errors\">An internal server error occurred. The operation failed.
                </e:Message>
            </detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

I am not sure what is the problem, or am I on the right track.

I would appreciate any suggestion on how to get users with EWS. The solutions that assumes modification on Office365 panel or in PowerShell access to Exchange are OK also.

Please advise on this.

Community
  • 1
  • 1
eomeroff
  • 9,599
  • 30
  • 97
  • 138
  • What is the end goal here? Is there a specific need to get the users through EWS/SOAP? If you want to administrate users on Exchange with powershell, there are much easier ways to do it through EMS cmdlets (gettable by import-pssession and your exchange hub fqdn) – Chris Kuperstein Mar 25 '16 at 16:45
  • @ChrisKuperstein The goal is to get all users from Exchange with EWS. If I do not need PowerShell even better. Thank you. – eomeroff Mar 25 '16 at 16:51
  • 1
    Why did you create a new global Address list ? you shouldn't being doing this normally. If you log onto to Outlook or OWA which GAL do you see ? The address list that you see in OWA or Outlook are the only address lists you will be able to access in EWS. – Glen Scales Mar 28 '16 at 03:49
  • @GlenScales based on your answer here http://stackoverflow.com/questions/35782101/how-to-get-all-users-form-exchange-with-ews I was thinking that I need to create GAL and use its ID as AddressListId. You are saying that I do not need to do that? Just to use existing GAL that I see Outlook or OWA and I will get all the contacts? OK. Then how do I get the AddressListId from the GAL that I see. Thank you very much. – eomeroff Mar 28 '16 at 07:10
  • @GlenScales When I log onto Outlook or OWA I see all rooms and users individually and some distribution list that I have created. Thank you. – eomeroff Mar 28 '16 at 07:54
  • 1
    You shouldn't be creating a new Gal, you just need to use the Get-GlobalAddressList cmdlet https://technet.microsoft.com/en-us/library/aa996579(v=exchg.160).aspx to get the Id of the default GAL that is being used. If you don't have access to the cmdlet you need to make sure the account your using has Address Lists Role in RBAC – Glen Scales Mar 28 '16 at 22:16
  • @GlenScales it works. you are the man. – eomeroff Mar 28 '16 at 23:29
  • @GlenScales I think I can manage it somehow. But just to ask while you are here. What would be correct way to separate rooms from users in the person list result. And If you could please post your last comment as a answer so I can accept it. Thank you. – eomeroff Mar 28 '16 at 23:32
  • You can do it one of two ways in the result you should be able to check the PersonaType which will be room from a Meeting Room. Otherwise you can use the other address lists (eg All Rooms from Outlook) you just use the Get-AddressList cmdlet to get the Guid like you did for the GAL and use it the same. – Glen Scales Mar 28 '16 at 23:46

1 Answers1

1

You shouldn't be creating a new Gal, you just need to use the Get-GlobalAddressList cmdlet technet.microsoft.com/en-us/library/aa996579(v=exchg.160).aspx to get the Id of the default GAL that is being used. If you don't have access to the cmdlet you need to make sure the account your using has Address Lists Role in RBAC

Glen

Glen Scales
  • 20,495
  • 1
  • 20
  • 23