DirectorySearcher.AttributeScopeQuery 屬性

定義

取得或設定要搜尋之辨別名稱屬性的 LDAP 顯示名稱, 只有一個屬性可用於這種類型的搜尋。

public:
 property System::String ^ AttributeScopeQuery { System::String ^ get(); void set(System::String ^ value); };
public string AttributeScopeQuery { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.DirectoryServices.DSDescription("DSAttributeQuery")]
[System.Runtime.InteropServices.ComVisible(false)]
public string AttributeScopeQuery { get; set; }
[System.DirectoryServices.DSDescription("DSAttributeQuery")]
[System.Runtime.InteropServices.ComVisible(false)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string AttributeScopeQuery { get; set; }
member this.AttributeScopeQuery : string with get, set
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
[<System.DirectoryServices.DSDescription("DSAttributeQuery")>]
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.AttributeScopeQuery : string with get, set
[<System.DirectoryServices.DSDescription("DSAttributeQuery")>]
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.AttributeScopeQuery : string with get, set
Public Property AttributeScopeQuery As String

屬性值

String

針對其執行搜尋之屬性的 LDAP 顯示名稱,如果未設定屬性範圍查詢,則為空字串。

屬性

例外狀況

SearchScope 屬性設為 Base 以外的值。

範例

下列範例示範如何搭配成員屬性使用 AttributeScopeQuery 屬性來取得群組的成員。 然後,它會列印成員的名字和姓氏及其電話號碼。

using System;
using System.DirectoryServices;  

public class Example
{
    public static void Main()
    {
        DirectoryEntry group = new DirectoryEntry("LDAP://CN=MyGroup", …);        
        DirectorySearcher src = new DirectorySearcher("(&(objectClass=user)(objectCategory=Person))");          
        src.AttributeScopeQuery = "member";  
        src.PropertiesToLoad.Add("sn");
        src.PropertiesToLoad.Add("givenName");  
        src.PropertiesToLoad.Add("telephoneNumber");  

        foreach(SearchResult res in src.FindAll())  
        {  
            Console.WriteLine("…");  
        }
    }
}

備註

此屬性設定為 的屬性必須是辨別名稱屬性,例如成員或 managedBy。 屬性可以是單一或多重值。 如需詳細資訊,請參閱 成員Managed-By 文章。

搜尋會針對基底物件之 屬性中指定的辨別名稱所識別的物件執行。 例如,如果基底物件是 adschema 群組類別,且 AttributeScopeQuery 設定為 「member」,則會針對屬於群組成員的所有物件執行搜尋。 如需詳細資訊,請參閱 群組類別 一文。

AttributeScopeQuery使用 屬性時, SearchScope 屬性必須設定為 Base 。 如果屬性 SearchScope 設定為任何其他值,則設定 AttributeScopeQuery 屬性將會擲回 ArgumentException

如需詳細資訊,請參閱 執行屬性範圍查詢

適用於