Getting a list of mailboxes with WebDAV

OK, WebDAV does not have the ability itself to get a list of mailboxes.  However you can use other APIs and even use an OWA call to get a list of mailboxes.


Reading the GAL:


WebDAV itself cannot do this.  You could use the OWA GALFIND command, which has some limited ability.  You could also use ADSI, CDO 1.21 or Extended MAPI as long as you’re running in-network.  There is no Exchange Web Service (EWS) call for doing this (at least not in Exchange 2007 SP1)).




GALFIND is an OWA call which is supported to use.  It is not a WebDAV call.  Basically, you do a GET against a URL and pass it search parameters.


Format of the OWA call:


sServerURL = "http://"+ sServerURL + "/public/?Cmd=galfind


Information on the unsupported call is covered in the following article:

Customizing Microsoft Outlook Web Access  


Basic call - use the following URI and choose "GET - OWA Call" - you will not need a body, all info past to OWA are in the uri:


http://<Exchange server>/exchange/?cmd=galfind


Here are the possible search Parameters:


      DN        Display Name                ex: Robert Jones

      FN        First Name                     ex: Robert

      LN         Last Name                    ex: Jones

      TL         Title                              ex: Big Manager

      AN        Alias                             ex: bobj

      CP        Company                      ex: microsoft   

      DP        Department                    ex: Exchange

      OF        Office                            ex: Bld 15/2124

      CY        City                               ex: Redmond


Note: There is no ability to search against other fields such as phone number, etc.


Example URIs:





Example Raw Request:


GET - OWA Call http://myexchangeserver/exchange/myuser/?cmd=galfind HTTP/1.1

Pragma: no-cache

Content-Type: text/xml

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)


Here are the supported methods:


CDO 1.21:

How To Work with Distribution Lists Using CDO (1.x) from Visual Basic 



241474 HOWTO: Render the Global Address List with ADSI 


Extended MAPI:

166106 HOWTO: Getting the Contents of the Exchange Global Address List 


More on using Extended MAPI to read the Mailbox Table:


The Mailbox Table in Exchange holds a list of Mailboxes and related mailbox information.  Reading this table can only be done with Extended MAPI or WMI can be used on an Exchange 2003 server.   


Extended MAPI can be used with Exchange 5.5 and later.


XCLN: How to Retrieve Last Logon Time of Exchange Users Using Extended MAPI;en-us;259570  


How to loop through mailboxes on Exchange by using the GetMailboxTable method


With Exchange 2003 and later, you can use WMI:


LastLogonTime Property 


Here is a sample of using GALFIND:


'  GALFIND Sample

' GALFIND will return results which can be consumed by your application as xml.

' You can test the URL by putting it into IE and seeing the results.

'  TODO: Have Basic Authentication turned ON on the virtual directory for the item and no anonymous.

'  Note: there is no Translate header set for a GET against an OWA URL – That’s because we are not using WebDAV, we are using the results from an OWA page.


sub ReadFileText (sFile)

    Dim objFSO 'As FileSystemObject

    dim oTS

    dim sText


    Set objFSO = CreateObject("Scripting.FileSystemObject")


    Set oTS = objFSO.OpenTextFile(sFile)

    sText = oTS.ReadAll



    set oTS = nothing

    Set objFSO = nothing


    ReadFileText = sText


end sub


Private Sub WriteFileText(sFilePath, sText)

    Dim objFSO 'As FileSystemObject

    Dim objTextFile 'As Object


    Const ForReading = 1

    Const ForWriting = 2

    Const ForAppending = 8


    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objTextFile = objFSO.CreateTextFile(sFilePath, True)


    ' Write a line.

    objTextFile.Write (sText)





End Sub



dim sHREF

dim sUserName 

dim sPassword 

dim sResponse 

Dim HttpWebRequest


shref="" mce_href=""  ' TODO: change


sUserName = "Administrator"    ' TODO: change

sPassword = ""    ' TODO: change


set HttpWebRequest = CreateObject("microsoft.xmlhttp")


if sPassword = "" then

    HttpWebRequest.Open "GET", sHREF , False


    HttpWebRequest.Open "GET", sHREF , False,  sUserName, sPassword

end if



sResponse  = HttpWebRequest.ResponseText  ' Returns as text


Set HttpWebRequest = Nothing

wscript.echo sResponse 



Comments (11)

  1. Webdav101 says:

    Under Exchange 2007, you can also use PowerShell to get the Global Address List – call Get-GlobalAddress List.  Exchange 2010 allows you to do remote calls using Remote PowerShell.  

    Please refer to the following:

  2. Webdav101 says:

    If your code .NET based, you should look at using the System.DirectoryServices namespace.  This allows you to search against AD to get the Global Address List.

  3. says:

    I'm trying to execute this using Jquery $.ajax command. It's working but I'm having trouble getting the XML data parsed and I think it's because there is <html> tags included with the response back from the exchange server url. Does anyone know how to get the raw xml back cleanly? I appreciate any assistance.

  4. Webdav101 says:


    Getting back an html tag back in the response is usually due to missing headers in the GET request. Are you using all of the headers?  … such as the Content-Type…?

    GET – OWA Call http://myexchangeserver/exchange/myuser/?cmd=galfind HTTP/1.1

    Pragma: no-cache

    Content-Type: text/xml

    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)

    Which version of Exchange are you going against?

  5. says:

    Thanks for the quick reply. We migrated to Exchange 2007-but i think we might still have a 2003 server.  I'm not using all the headers you mentioned. Let me try that and I'll post my results.

  6. says:

    I tried adding all the headers but it's still returning html in the response. Do you happen to have an example of this using JQuery, rather than asp/vb ? I'm attempting to build a mobile app that can access this data so it would need to run client side.

  7. Webdav101 says:

    I don't have any JQuery examples.  Are you using the "exchange" virtual directory or "owa"?  It should be "exchange" – the same as it was for 2003.  Have  you tried the VBScript sample above to see if you get the same response?

  8. fnando521 says:

    I'll try your vb sample and see if I get the same results. The url I use is https://exchangeserver/public/?cmd=galfind&fn=bob

    It returns the correct data in the browser but also includes <html>.

  9. Hey fnando521 – I ran into the same exact thing.  Try adding some UserAgent settings stuff in your code.  You can hit it that way with JQuery, dude.  Good luck with that one and let me know how it works out.  Peace.

  10. Fnando521 says:

    Yeah I needed to add the correct 'User-Agent' in the request header, and now I'm able to get the data correctly! Thanks!

Skip to main content