Reputation: 1626
im using EWS on a Exchange 2010 SP2 server
i cant seem to find any command/documentation for retrieving a complete list of all users (mailboxes/aliases) in the exchange server
the question has been asked several times but i havent seen any answer
thanks
Upvotes: 3
Views: 4307
Reputation: 22032
In 2010 with EWS there is no operation that will return this you only have the ResolveName operation and the expandgroup operation. So in EWS you can use a workaround of putting all the users you want to be returned in a group and then using ExpandGroup on that Group.
Otherwise you should use either LDAP directly using System.DirectoryServices eg http://www.infinitec.de/post/2011/10/25/Searching-the-Global-Address-List-C-Edition.aspx or use the Exchange Management Shell and Get-Mailbox see http://msdn.microsoft.com/en-us/library/office/ff326159(v=exchg.150).aspx
One other workaround is if you have less the 100 objects in your GAL you can use "SMTP:" with resolveName eg
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
Upvotes: 4