Can we use EDSM ADSI provider to search based on the built-in custom Exchange attribute "edsva-MsExch-ActiveMailboxServerName" ?
The code below return 0 result even though there are a lot users has value of the attribute "edsva-MsExch-ActiveMailboxServerName"
If we change the search filter to another attribute "sn", it will work
filter.Append("(&(sn=" + sSN + "))");
==============================================================================
const AuthenticationTypes ADS_EDMSERVER_BIND = (AuthenticationTypes)32678;
DirectoryEntry strDefaultNamingContext = new DirectoryEntry("EDMS://servername/DC=test,DC=com");
strDefaultNamingContext.AuthenticationType = ADS_EDMSERVER_BIND;
strDefaultNamingContext.Username = @"NIH\" + userID;
strDefaultNamingContext.Password = userPW;
// DirectorySearcher
DirectorySearcher ConfigSearcher = new DirectorySearcher(strDefaultNamingContext);
ConfigSearcher.SearchRoot = strDefaultNamingContext;
StringBuilder filter = new StringBuilder();
filter.Append("(&(edsva-MsExch-ActiveMailboxServerName=" + sExServer + "))");
ConfigSearcher.Filter = filter.ToString();
ConfigSearcher.PropertiesToLoad.Add("edsva-msexch-activemailboxservername");
ConfigSearcher.PropertiesToLoad.Add("sn");
ConfigSearcher.SearchScope = SearchScope.Subtree;
SearchResultCollection results = ConfigSearcher.FindAll();
foreach (SearchResult result in results)
{
s = result.Properties["sn"][0].ToString();
Response.Write(s);
}
//cleanUp
strDefaultNamingContext.Close();
strDefaultNamingContext.Dispose();
ConfigSearcher.Dispose();
results.Dispose();