Partage via


DirectorySearcher.AttributeScopeQuery Propriété

Définition

Obtient ou définit le nom complet LDAP de l’attribut de nom unique dans lequel effectuer une recherche. Un seul attribut peut être utilisé pour ce type de recherche.

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

Valeur de propriété

Nom complet LDAP de l’attribut sur lequel effectuer la recherche, ou une chaîne vide d’aucune requête d’étendue d’attribut n’est définie.

Attributs

Exceptions

La SearchScope propriété est définie sur une valeur autre que Base.

Exemples

L’exemple suivant montre comment utiliser la AttributeScopeQuery propriété avec l’attribut membre pour obtenir les membres d’un groupe. Il imprime ensuite les prénoms et noms des membres et leurs numéros de téléphone.

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("…");
        }
    }
}

Remarques

L’attribut défini par cette propriété doit être un attribut de nom unique, tel que membre ou managedBy. L’attribut peut être à valeur unique ou à valeurs multiples. Pour plus d’informations, consultez les articles Member et Managed-By .

La recherche est effectuée sur les objets identifiés par le nom unique spécifié dans l’attribut de l’objet de base. Par exemple, si l’objet de base est une classe de groupe adschema et que la AttributeScopeQuery valeur est « membre », la recherche est effectuée sur tous les objets membres du groupe. Pour plus d’informations, consultez l’article de classe Groupe .

Lorsque la AttributeScopeQuery propriété est utilisée, la SearchScope propriété doit être définie sur Base. Si la SearchScope propriété est définie sur une autre valeur, la définition de la AttributeScopeQuery propriété lève un ArgumentException.

Pour plus d’informations, consultez l’exécution d’une requête d’étendue d’attribut.

S’applique à