2016-08-14 15 views
0

Active Directoryでの作業は非常に新しいです。ウェブでしばらく時間を費やした後、DirectorySearcherクラスを使用してアクティブディレクトリからユーザーを取得するためのコードを取得できました。しかし、私は、サポートされているすべての句と検索キーワードのリストを取得するのに苦労しています。DirectorySearcher - 検索の句とキーワード

入手できる唯一のリンクはhttps://msdn.microsoft.com/en-us/library/aa746475(v=vs.85).aspxです。しかし、いくつかのキーワードしか得られません。

リンクやキーワードと句のリストを親切に共有します。以下は私が見つけたものです。

  • (!userAccountControl:1.2.840.113556.1.4.803:=2))
  • (manager=...)
  • (!msExchResourceMetaData=ResourceType:Room)
  • (objectCategory=person)
  • &(objectClass=user)
    1. はまた、私はMSを使用して組織図を作成しようとしました。 Visio、次に DirectorySearcherコードを入力します。 [email protected]や会議室などの仮想アカウントはVisioのファイルから除外されますが、ディレクトリサーチャーコードで取得できます。

      助けてください。

    +0

    [RFC2254](https://www.ietf.org/rfc/rfc2254.txt)を書き換えようとしていますか?* ADSIはRFC2254 *で定義されているLDAP検索フィルタをサポートしていますか? – rene

    答えて

    0

    は、.NET 3.5以降を使用していると仮定すると、あなたはあなたがはるかに簡単にDirectorySearcher「低レベル」よりも検索を行うことPrincipalSearcherと「例による問合せ」プリンシパルを使用することができます。

    // create your domain context 
    using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain)) 
    { 
        // define a "query-by-example" principal - here, we search for a UserPrincipal 
        // and with the first name (GivenName) of "Bruce" and a last name (Surname) of "Miller" 
        UserPrincipal qbeUser = new UserPrincipal(ctx); 
        qbeUser.GivenName = "Bruce"; 
        qbeUser.Surname = "Miller"; 
    
        // create your principal searcher passing in the QBE principal  
        PrincipalSearcher srch = new PrincipalSearcher(qbeUser); 
    
        // find all matches 
        foreach(var found in srch.FindAll()) 
        { 
         // do whatever here - "found" is of type "Principal" - it could be user, group, computer.....   
        } 
    } 
    

    MSDNの記事Managing Directory Security Principals in the .NET Framework 3.5 (MSDN Mag, Jan 2008 issue)をまだ読んでいない方は、System.DirectoryServices.AccountManagementの新機能の使い方をうまく示してください。またはMSDN documentation on the System.DirectoryServices.AccountManagement名前空間を参照してください。

    • DisplayName(通常:最初の名+スペース+姓もちろん

      、あなたの必要性に応じて、あなたが作成する「例による問合せ」ユーザープリンシパル上の他のプロパティを指定したい場合があります)

    • SAM Account Nameから
    • User Principal NameあなたのWindows/ADアカウント名 - あなたの "[email protected]" スタイル名

    あなたがSPEすることができますUserPrincipalのいずれかのプロパティを確認して、PrincipalSearcherの「クエリバイケース」として使用します。

    関連する問題