Get a complete list of users in Microsoft Exchange

im using EWS on Exchange 2010 SP2

I cannot find any command / documentation for getting a complete list of all users (mailboxes / aliases) on the exchange server

the question has been asked several times but I have not seen any answer



source to share

1 answer

In 2010 with EWS, there is no operation that will return this, you will only have a ResolveName operation and an expandgroup operation. So in EWS, you can use a workaround to place all the users you want to return to a group and then use ExpandGroup on that group.

Otherwise, you have to use LDAP directly using System.DirectoryServices like or use Exchange Management Shell and Get-Mailbox see

Another workaround is if you have less than 100 objects in your GAL, you can use "SMTP:" with the resolveName, for example

        PropertySet cntProp = new PropertySet(BasePropertySet.FirstClassProperties);
        NameResolutionCollection ncCol = service.ResolveName("SMTP:", ResolveNameSearchLocation.DirectoryOnly, true, cntProp);
        foreach (NameResolution nc in ncCol) { 
            if(nc.Contact.Alias != null){
                Console.WriteLine("Address : " + nc.Mailbox.Address);
                Console.WriteLine("Alias : " + nc.Contact.Alias);
                Console.WriteLine("Type : " + nc.Mailbox.MailboxType);


Cheers Glen



All Articles