none
Getting all contacts from GAL using EWS RRS feed

  • Question

  • Hello,

    I develop a c++ application using SOAP request to access to an exchange server.  And I'm trying to get all contacts, I can already get all personals contacts but I can't get the GAL contacts.

    How can i do this ?

    thanks for your answers.

    Tuesday, February 9, 2016 2:03 PM

Answers

  • That isn't the correct Id and you won't be able to get the Id you need from Outlook you need to use the Get-GlobalAddressList cmdlet https://technet.microsoft.com/en-us/library/aa996579(v=exchg.160).aspx in Exchange Management Shell which will return what you need.

    Cheers
    Glen

    • Marked as answer by thibbocli Thursday, February 18, 2016 1:33 PM
    Tuesday, February 16, 2016 12:55 AM
  • You need to use the AddressId type with the GUID of the address list you want to access and page the result eg

    <?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="5c90c254-2463-4256-bf52-60d82e6baa44" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
          </ParentFolderId>
        </FindPeople>
      </soap:Body>
    </soap:Envelope>
    Cheers
    Glen

    • Marked as answer by thibbocli Thursday, February 18, 2016 1:35 PM
    Friday, February 12, 2016 2:43 AM

All replies

  • Hi,

    I am not sure which URL you are using with SOAP to access Exchange. As per my understanding you need to use the EWS URL to get this information.

    That URL could be - http://Your_exchange_server_name/EWS/Services.wsdl

    More details can be found here - http://vivekiyer.net/2010/07/17/querying-the-global-address-list-gal-via-exchange-web-services-ews/

    -----
    Remember to mark as helpful if you find my contribution useful or as an answer if it does answer your question.That will encourage me - and others - to take time out to help you Thanks Gurpreet


    Gurpreet Singh

    Tuesday, February 9, 2016 2:12 PM
  • for example, i use this soap request to get all personals contacts :

    string  soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    	soapRequest += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n";
    	soapRequest += "  xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" \n";
    	soapRequest += "   xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">\n";
    	soapRequest += "	<soap:Header>\n";
    	soapRequest += "		<t:RequestServerVersion Version=\"Exchange2010\" />\n";
    	soapRequest += "	</soap:Header>\n";
    	soapRequest += "	<soap:Body>\n";
    	soapRequest += "		<m:FindItem Traversal=\"Shallow\">\n";
    	soapRequest += "			<m:ItemShape>\n";
    	soapRequest += "				<t:BaseShape>Default</t:BaseShape>\n";
    	soapRequest += "			</m:ItemShape>\n";
    	soapRequest += "			<m:IndexedPageItemView BasePoint=\"Beginning\" MaxEntriesReturned=\"100\" Offset=\"0\"/>\n";
    	soapRequest += "			<m:ParentFolderIds>\n";
    	soapRequest += "				<t:DistinguishedFolderId Id=\"contacts\"/>\n";
    	soapRequest += "			</m:ParentFolderIds>\n";
    	soapRequest += "		</m:FindItem>\n";
    	soapRequest += "	</soap:Body>\n";
    	soapRequest += "</soap:Envelope>\n";

    and I've already try with resolvenames but with this method I can only get the 100 first contacts in the GAL. Here is the soap request :

    	soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    	soapRequest += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n";
    	soapRequest += "  xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" \n";
    	soapRequest += "   xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">\n";
    	soapRequest += "	<soap:Header>\n";
    	soapRequest += "		<t:RequestServerVersion Version=\"Exchange2010\" />\n";
    	soapRequest += "	</soap:Header>\n";
    	soapRequest += "	<soap:Body>\n";
    	soapRequest += "		<m:ResolveNames ReturnFullContactData=\"true\" SearchScope=\"ContactsActiveDirectory\">\n";
    	soapRequest += "			<m:UnresolvedEntry>smtp</m:UnresolvedEntry>\n";
    	soapRequest += "		</m:ResolveNames>\n";
    	soapRequest += "	</soap:Body>\n";
    	soapRequest += "</soap:Envelope>\n";

    and the part of the response where exchange says that all contacts are not in response:

    <m:ResponseMessages>
        <m:ResolveNamesResponseMessage ResponseClass="Warning">
        <m:MessageText>Multiple results were found.</m:MessageText>
        <m:ResponseCode>ErrorNameResolutionMultipleResults</m:ResponseCode>
        <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>
        <m:ResolutionSet TotalItemsInView="100" IncludesLastItemInRange="false">


    • Edited by thibbocli Tuesday, February 9, 2016 2:34 PM
    Tuesday, February 9, 2016 2:19 PM
  •   up
    Wednesday, February 10, 2016 2:54 PM
  • ResolveName is restricted to returning 100 items only. If you using Exchange 2013,16 or Office365 and you know the GUID of the Global Address List (or other address list you want to access) then you can use the FindPeople operation https://msdn.microsoft.com/en-us/library/office/jj191039(v=exchg.150).aspx and page the results eg http://gsexdev.blogspot.com.au/2013/05/using-ews-findpeople-operation-in.html

    Cheers
    Glen

    Thursday, February 11, 2016 5:15 AM
  • I first i tried with exchange 2010 but now I'm trying with exchange 2013 but I'm not able to get all the contacts.

    I send this request :

            soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    	soapRequest += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n";
    	soapRequest += "  xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" \n";
    	soapRequest += "   xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">\n";
    	soapRequest += "	<soap:Header>\n";
    	soapRequest += "		<t:RequestServerVersion Version=\"Exchange2013\" />\n";
    	soapRequest += "	</soap:Header>\n";
    	soapRequest += "	<soap:Body>\n";
    	soapRequest += "		<m:FindPeople>\n";
    	soapRequest += "			<m:PersonaShape>\n";
    	soapRequest += "				<t:BaseShape>Default</t:BaseShape>\n";
    	soapRequest += "			</m:PersonaShape>\n";
    	soapRequest += "			<m:IndexedPageItemView BasePoint=\"Beginning\" MaxEntriesReturned=\"100\" Offset=\"0\"/>\n";
    	soapRequest += "			<m:ParentFolderId>\n";
    	soapRequest += "				<t:DistinguishedFolderId Id=\"directory\"/>\n";
    	soapRequest += "			</m:ParentFolderId>\n";
    	soapRequest += "		</m:FindPeople>\n";
    	soapRequest += "	</soap:Body>\n";
    	soapRequest += "</soap:Envelope>\n";

    and the response is :

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
            <h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="1130" MinorBuildNumber="6" Version="V2_23" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <FindPeopleResponse ResponseClass="Error" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
                <MessageText>The distinguished folder name is unrecognized.</MessageText>
                <ResponseCode>ErrorInvalidOperation</ResponseCode>
                <DescriptiveLinkKey>0</DescriptiveLinkKey>
                <TotalNumberOfPeopleInView>0</TotalNumberOfPeopleInView>
                <FirstMatchingRowIndex>0</FirstMatchingRowIndex>
                <FirstLoadedRowIndex>0</FirstLoadedRowIndex>
            </FindPeopleResponse>
        </s:Body>
    </s:Envelope>

    • Edited by thibbocli Thursday, February 11, 2016 9:47 AM
    Thursday, February 11, 2016 7:47 AM
  • I tried that too :

    	soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    	soapRequest += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n";
    	soapRequest += "  xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" \n";
    	soapRequest += "   xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">\n";
    	soapRequest += "	<soap:Header>\n";
    	soapRequest += "		<t:RequestServerVersion Version=\"Exchange2013\" />\n";
    	soapRequest += "	</soap:Header>\n";
    	soapRequest += "	<soap:Body>\n";
    	soapRequest += "		<m:FindPeople>\n";
    	soapRequest += "			<m:PersonaShape>\n";
    	soapRequest += "				<t:BaseShape>Default</t:BaseShape>\n";
    	soapRequest += "			</m:PersonaShape>\n";
    	soapRequest += "			<m:IndexedPageItemView BasePoint=\"Beginning\" MaxEntriesReturned=\"100\" Offset=\"0\"/>\n";
    	soapRequest += "			<m:ParentFolderId>\n";
    	soapRequest += "				<t:FolderId Id=\"4e951971-836c-4512-bdc4-12219b08ae73\"/>\n";
    	soapRequest += "			</m:ParentFolderId>\n";
    	soapRequest += "		</m:FindPeople>\n";
    	soapRequest += "	</soap:Body>\n";
    	soapRequest += "</soap:Envelope>\n";

    but the server respond that the id is malformed :

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
            <h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="1130" MinorBuildNumber="6" Version="V2_23" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <FindPeopleResponse ResponseClass="Error" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
                <MessageText>Id is malformed.</MessageText>
                <ResponseCode>ErrorInvalidIdMalformed</ResponseCode>
                <DescriptiveLinkKey>0</DescriptiveLinkKey>
                <TotalNumberOfPeopleInView>0</TotalNumberOfPeopleInView>
                <FirstMatchingRowIndex>0</FirstMatchingRowIndex>
                <FirstLoadedRowIndex>0</FirstLoadedRowIndex>
            </FindPeopleResponse>
        </s:Body>
    </s:Envelope>

    Thursday, February 11, 2016 10:01 AM
  • You need to use the AddressId type with the GUID of the address list you want to access and page the result eg

    <?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="5c90c254-2463-4256-bf52-60d82e6baa44" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" />
          </ParentFolderId>
        </FindPeople>
      </soap:Body>
    </soap:Envelope>
    Cheers
    Glen

    • Marked as answer by thibbocli Thursday, February 18, 2016 1:35 PM
    Friday, February 12, 2016 2:43 AM
  • I think the list I use is too big for exchange because when I send this request :

    	soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
    	soapRequest += "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"\n";
    	soapRequest += "  xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\" \n";
    	soapRequest += "   xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\">\n";
    	soapRequest += "	<soap:Header>\n";
    	soapRequest += "		<t:RequestServerVersion Version=\"Exchange2013_SP1\" />\n";
    	soapRequest += "	</soap:Header>\n";
    	soapRequest += "	<soap:Body>\n";
    	soapRequest += "		<m:FindPeople>\n";
    	soapRequest += "			<m:PersonaShape>\n";
    	soapRequest += "				<t:BaseShape>Default</t:BaseShape>\n";
    	soapRequest += "			</m:PersonaShape>\n";
    	soapRequest += "			<m:IndexedPageItemView BasePoint=\"Beginning\" MaxEntriesReturned=\"100\" Offset=\"0\"/>\n";
    	soapRequest += "			<m:ParentFolderId>\n";
    	soapRequest += "				<t:AddressListId Id=\"4e951971-836c-4512-bdc4-12219b08ae73\"/>\n";
    	soapRequest += "			</m:ParentFolderId>\n";
    	soapRequest += "		</m:FindPeople>\n";
    	soapRequest += "	</soap:Body>\n";
    	soapRequest += "</soap:Envelope>\n";

    I recieve this :

    <?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Body>
            <s:Fault>
                <faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorInternalServerError</faultcode>
                <faultstring xml:lang="fr-BE">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>


    • Edited by thibbocli Friday, February 12, 2016 8:27 AM
    Friday, February 12, 2016 8:22 AM
  • Try removing the Persona shape and sending the request as I have formatted it just changing the Id to something that is valid (this is a working example)

    Rgds
    Glen

    Monday, February 15, 2016 1:44 AM
  • I just realise that I used the wrong Id.  The Id I was using was here :

    https://www.dropbox.com/s/u96mjv0pios0eli/test1.png?dl=0

    https://www.dropbox.com/s/jurb1e9jkq55u5k/test.png?dl=0

    (sorry I can't post picture because my account is not verified yet)

    but I think it's not the id i must used because when I change the id in my request I've got the same error response.


    • Edited by thibbocli Monday, February 15, 2016 7:24 AM
    Monday, February 15, 2016 7:22 AM
  • That isn't the correct Id and you won't be able to get the Id you need from Outlook you need to use the Get-GlobalAddressList cmdlet https://technet.microsoft.com/en-us/library/aa996579(v=exchg.160).aspx in Exchange Management Shell which will return what you need.

    Cheers
    Glen

    • Marked as answer by thibbocli Thursday, February 18, 2016 1:33 PM
    Tuesday, February 16, 2016 12:55 AM
  • Thank you it works perfectly.

    Thursday, February 18, 2016 1:35 PM