0
を使用して、すべてのプロパティ名を取得できません。私はこのコードを持っている:C#の:DirectoryEntryの
DirectoryEntry entry = new DirectoryEntry(_path + domain, domainAndusernam, password);
try
{
Object obj = entry.NativeObject;
string department, title;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("department");
search.PropertiesToLoad.Add("title");
SearchResult result = search.FindOne();
if (result == null)
{
return false;
}
_path = result.Path;
_filterAttribute = (string)result.Properties["cn"][0];
department = (string)result.Properties["department"][0];
title = (string)result.Properties["title"][0];
return true;
}
catch (Exception)
{
return false;
}
私の問題は、私はのSearchResultからすべてのプロパティ名を取得するように見えることはできません。私は "cn"と "mail"を得ることができましたが、 "department"や "title"のような他のプロパティは取得できませんでした。ここに何か間違っていますか?
私はそれを理解していますが、私が期待している "部署"と "タイトル"のプロパティには価値があると確信しています。ちょっと前に、このコードを別のアプリケーションとマシンで実行しようとしましたが、同じパスとドメインを使用する2つのプロパティー名を含む少なくとも54のプロパティー名を取得できました。マシンと何か関係がある可能性はありますか?私は最初の試しにはラップトップを使い、2回目にはデスクトップを使いました。 –