views:

444

answers:

2

I need to search for all users containing a certain text string in their name against the Exchange Server Global Address List. This operation will be performed from an ASP.NET application. Note that the GAL is required (not Active Directory) as it contains users across domains. It's also what the customer requested.

I've been looking at Exchange Web Services and Outlook Web Access methods. However neither may be configured in my organisation so I need to know which option is the right one before asking infrastructure to configure it.

Exchange Web Services

I hoped to use the ResolveNames method in Exchange Web Services. The documentation for it states that:

Active Directory is searched first, and then the user's contact folder is searched.

It appears to imply that this method will only return users from the current domain. Is this correct?

Outlook Web Access

The other option I found was GALFind. This looks perfect but this article stated that it is unsupported. It is confirmed as no longer available in this Technet article.

Can anyone please give advice on these or any other options?

A: 

I'm no Exchange expert but can't you do this using Collaboration Data Objects (CDO) although it might not be too swift.

serialhobbyist
+1  A: 

It is possible to query across domains by starting the query from the forest root. Here is the code I ended up using:

string filter = "(&(objectCategory=person)(objectClass=user)(name=*" + search + "*))";
var rootEntry = new DirectoryEntry("GC:");
foreach (DirectoryEntry entry in rootEntry.Children)
{
    DirectoryEntry forestEntry = entry;
    DirectorySearcher searcher = new DirectorySearcher
     {
      SearchRoot = forestEntry,
      Filter = filter,
      Sort =
       {
        Direction = SortDirection.Ascending,
        PropertyName = "cn"
       }
     };
    searcher.PropertiesToLoad.AddRange(ADProperties.Values.ToArray());
    SearchResultCollection results = searcher.FindAll();
    foreach (SearchResult result in results)
    {
     DirectoryEntry foundEntry = result.GetDirectoryEntry();

     // Do something
    }
}
Alex Angas