Edit

Bagikan melalui


DirectorySearcher.AttributeScopeQuery Property

Definition

Gets or sets the LDAP display name of the distinguished name attribute to search in. Only one attribute can be used for this type of search.

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

Property Value

The LDAP display name of the attribute to perform the search against, or an empty string of no attribute scope query is set.

Attributes

Exceptions

The SearchScope property is set to a value other than Base.

Examples

The following example shows how to use the AttributeScopeQuery property with the member attribute to get the members of a group. It then prints out the first and last names of the members and their telephone numbers.

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.SearchRoot = group;
        src.AttributeScopeQuery = "member";  
        src.PropertiesToLoad.Add("sn");
        src.PropertiesToLoad.Add("givenName");  
        src.PropertiesToLoad.Add("telephoneNumber");  

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

Remarks

The attribute that this property is set to must be a distinguished name attribute, such as member or managedBy. The attribute can be either single or multi-valued. For more information, see the Member and Managed-By articles.

The search is performed against the objects that are identified by the distinguished name that is specified in the attribute of the base object. For example, if the base object is an adschema group class and the AttributeScopeQuery is set to "member," then the search will be performed against all objects that are members of the group. For more information, see the Group class article.

When the AttributeScopeQuery property is used, the SearchScope property must be set to Base. If the SearchScope property is set to any other value, setting the AttributeScopeQuery property will throw an ArgumentException.

For more information, see the Performing an Attribute Scope Query.

Applies to