ローカル コンピューター (最初に実行) または現在のフォレストでユーザー グループを検索するために、次の方法を使用しています。
public string FindUserGroup(string group)
{
//Search local computer
using (DirectorySearcher searcher = new DirectorySearcher(new DirectoryEntry()))
{
searcher.Filter = "(&(objectClass=group)(|(cn=" + group + ")(dn=" + group + ")))";
SearchResult result = searcher.FindOne();
if (result != null)
return TranslateDirectoryEntryPath(result.GetDirectoryEntry().Path);
}
//Search current forest
Forest forest = Forest.GetCurrentForest();
foreach (Domain domain1 in forest.Domains)
{
using (DirectorySearcher searcher = new DirectorySearcher(domain1.GetDirectoryEntry()))
{
searcher.Filter = "(&(objectClass=group)(|(cn=" + group + ")(dn=" + group + ")))";
SearchResult result = searcher.FindOne();
if (result != null)
return TranslateDirectoryEntryPath(result.GetDirectoryEntry().Path);
}
}
return string.Empty;
}
私の問題は、例として「domain.local」と「mydomain.local」があり、現在のログインが「domain.local」にバインドされているため、以下を使用しても「mydomain.local」で何も見つからないことです。ローカル"、たとえ Windows ユーザー インターフェイスを使用しても、できます。
すべての表示可能なプロバイダーを必ずしもすべて知っているわけではないのに、自分のコンピューターの観点からすべての表示可能なプロバイダーを検索するにはどうすればよいですか? レジストリ作業は本当に自分で行う必要がありますか?
編集:
2 つのドメインの違いの 1 つは、オブジェクト ブラウザ ダイアログで [場所] を選択したときの「レベル」です。次のようにレイアウトされます。
- コンピューター
- 全方向
- ドメイン.ローカル
- mydomain.local
したがって、「mydomain.local」は「ディレクトリ全体」と呼ばれるものの外に存在しますが、私のコンピューターはそれを見つけることができますか?