2
私のコンソールアプリケーションからXXXドメインのディレクトリにアクセスしようとしています。C#からのアクティブディレクトリへのアクセス
DirectoryEntry oDE = new DirectoryEntry("LDAP://DC=XXXX,DC=myDomain,DC=com");
using (DirectorySearcher ds = new DirectorySearcher(oDE))
{
ds.PropertiesToLoad.Add("name");
ds.PropertiesToLoad.Add("userPrincipalName");
ds.Filter = "(&(objectClass=user))";
SearchResultCollection results = ds.FindAll();
foreach (SearchResult result in results)
{
Console.WriteLine("{0} - {1}",
result.Properties["name"][0].ToString(),
result.Properties["userPrincipalName"][0].ToString());
}
}
行がSearchResultCollectionの結果= ds.FindAll();実行すると、「サーバー上にこのようなオブジェクトがありません」というエラーが表示されます。
私は間違っているのですか?コメントで私たちの「チャット」の
ディレクトリエントリにアクセスするための認証を提供する必要がありますか? – Roshe
LDAP Uriの他の3つの部分も必ず変更しましたか?ドメインがDomainXXX.lanの場合DC = DomainXXX、DC = lanである必要があります – NKCSS
外部ドメイン= XXXX.com MyDomain = test.com DirectoryEntry oDE = new DirectoryEntry( "LDAP://DC=XXX.com,DC=test,DC=com "); これは方法だと思います。 – Roshe