8

ActiveDirectoryでユーザー名でユーザーを検索しようとしています。

これは機能します:

const string Domain = "SLO1.Foo.Bar.biz";
const string Username = "sanderso";

PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, Domain);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext,  Username);

これはしません:

const string Domain = "SLO1.Foo.Bar.biz";
const string Container = "CN=Users,DC=SLO1,DC=Foo,DC=Bar,DC=biz";
const string Username = "sanderso";

PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, Domain, Container);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, Username);

エラーメッセージが表示されます:

サーバー上にそのようなオブジェクトはありません。

これが私のActiveDirectoryセットアップのスクリーンショットです:

ここに画像の説明を入力してください

また、次のコンテナを使用してみました。

const string Container = "OU=Users,DC=SLO1,DC=Foo,DC=Bar,DC=biz";

これも同様に失敗しました。

'Users'コンテナにアクセスしているときにコンテナを指定するにはどうすればよいですか?より複雑な要件を持つルックアップを導入する前に、これを初期の単純なセットアップとして実行しようとしています。とにかくこれをトラブルシューティングする必要があるので、私は単純な解決策に甘んじたくありません、と私は信じています。

4

1 に答える 1

9

私はそれを考え出した :)

まず、次のソフトウェアを使用して、適切なコンテナ文字列を生成していることを確認しました。

http://www.ldapbrowser.com/download.htm

これにより、ポートが欠落していることを除けば、私の文字列がほぼ正しいことが確認されましたが、多少の手間が必要でした。

正しい使用法は次のとおりです。

const string Domain = "SLO1.Foo.Bar.biz:389";
const string Container = @"DC=Foo,DC=Bar,DC=biz";
const string Username = @"sanderso";
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, Domain, Container);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext,  username);
于 2013-01-07T23:56:52.737 に答える