私はADで特定のユーザーのクエリを行い、複数のプロパティのリストを作成しようとしています。以下のコード。 searchResult.Properties ["manager"]またはsearchResult.Properties ["mail"]を実行すると、正しい結果が得られます。しかし、私はどのように複数のプロパティを検索するのだろうか?は、Active Directoryで複数のプロパティを検索するのに役立つ必要があります
DirectoryEntry dEntry = new DirectoryEntry(path);
DirectorySearcher dSearcher = new DirectorySearcher(dEntry);
dSearcher.Filter = "(&(ObjectClass=user)(samaccountname=mcavanaugh))";
sResults = dSearcher.FindAll();
foreach (SearchResult searchResult in sResults)
{
var sAMAccountName = searchResult.Properties["samaccountname"][0].ToString().ToLower();
if (sAMAccountName == "mcavanaugh")
{
//Right here is where i would select multiple ad properties
ResultPropertyValueCollection valueCollection = searchResult.Properties["manager, mail"];
foreach (Object propertyValue in valueCollection)
{
var PropertyName = (string)propertyValue.ToString();
testlist.Text = PropertyName;
}
}
}