Export (0) Print
Expand All

DirectorySearcher.AttributeScopeQuery Property

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.

Namespace:  System.DirectoryServices
Assembly:  System.DirectoryServices (in System.DirectoryServices.dll)

[ComVisibleAttribute(false)]
[DSDescriptionAttribute("DSAttributeQuery")]
[TypeConverterAttribute("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string AttributeScopeQuery { get; set; }

Property Value

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

ExceptionCondition
ArgumentException

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

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 adschema topics "Member" and "Managed-By" in the MSDN Library at http://msdn.microsoft.com/library.

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 adschema "Group" class topic in the MSDN Library at http://msdn.microsoft.com/library.

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" topic in the MSDN Library at http://msdn.microsoft.com/library).

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.DirectoryServices;
DirectoryEntry group = new DirectoryEntry("LDAP://CN=MyGroup, …");
DirectorySearcher src = new DirectorySearcher(group "(&(objectClass=user)(objectCategory=Person))");
src.AttributeScopedQuery = "member";
src.PropertiesToLoad.Add("sn");
src.PropertiesToLoad.Add("givenName");
src.PropertiesToLoad.Add("telephoneNumber");
foreach(SearchResult res in src.FindAll())
{
    Console.WriteLine("…");
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft