DirectorySearcher 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
对 Active Directory 域服务执行查询。
public ref class DirectorySearcher : System::ComponentModel::Componentpublic class DirectorySearcher : System.ComponentModel.Component[System.DirectoryServices.DSDescription("DirectorySearcherDesc")]
public class DirectorySearcher : System.ComponentModel.Componenttype DirectorySearcher = class
    inherit Component[<System.DirectoryServices.DSDescription("DirectorySearcherDesc")>]
type DirectorySearcher = class
    inherit ComponentPublic Class DirectorySearcher
Inherits Component- 继承
- 属性
注解
DirectorySearcher使用 对象通过轻型目录访问协议 (LDAP) 搜索并针对 Active Directory 域服务层次结构执行查询。 LDAP 是系统提供的唯一 Active Directory 服务接口 (ADSI) 提供程序,支持目录搜索。 管理员可以创建、更改和删除在层次结构中找到的对象。 有关详细信息,请参阅 使用 System.DirectoryServices。
创建 的 DirectorySearcher实例时,指定要检索的根,以及要检索的属性的可选列表。 属性 SearchRoot 使你可以设置其他属性以执行以下任务:
- 在本地计算机上缓存搜索结果。 将 CacheResults 属性设置为 以 - true在本地计算机上存储目录信息。 仅当调用 方法时 DirectoryEntry.CommitChanges ,才会对此本地缓存进行更新并提交到 Active Directory 域服务。
- 使用 ServerTimeLimit 属性指定搜索的时间长度。 
- 仅检索属性名称。 将 PropertyNamesOnly 属性设置为 以 - true仅检索已向其分配值的属性的名称。
- 执行分页搜索。 PageSize设置 属性以指定分页搜索中返回的最大对象数。 如果不想执行分页搜索,请将 PageSize 属性设置为其默认值零。 
- 使用 SizeLimit 属性指定要返回的最大条目数。 如果将 属性设置为 SizeLimit 其默认值零,则服务器确定的默认值为 1000 个条目。 
注意
如果返回的最大条目数和时间限制超过了服务器上设置的限制,则服务器设置将覆盖组件设置。
有关 DirectorySearcher 类的实例的初始属性值列表,请参见 DirectorySearcher() 构造函数。
注意
在使用此类之前,假定你已大致了解 Active Directory 域服务。 有关详细信息,请参阅 System.DirectoryServices 概述。
构造函数
| DirectorySearcher() | 使用默认值初始化 DirectorySearcher 类的新实例。 | 
| DirectorySearcher(DirectoryEntry) | 使用指定的搜索根初始化 DirectorySearcher 类的新实例。 | 
| DirectorySearcher(DirectoryEntry, String) | 使用指定的搜索根和搜索筛选器初始化 DirectorySearcher 类的新实例。 | 
| DirectorySearcher(DirectoryEntry, String, String[]) | 使用指定的搜索根、搜索筛选器和要检索的属性初始化 DirectorySearcher 类的新实例。 | 
| DirectorySearcher(DirectoryEntry, String, String[], SearchScope) | 使用指定的搜索根、搜索筛选器、要检索的属性和搜索范围初始化 DirectorySearcher 类的新实例。 | 
| DirectorySearcher(String) | 使用指定的搜索筛选器初始化 DirectorySearcher 类的新实例。 | 
| DirectorySearcher(String, String[]) | 使用指定的搜索筛选器和要检索的属性初始化 DirectorySearcher 类的新实例。 | 
| DirectorySearcher(String, String[], SearchScope) | 使用指定的搜索筛选器、要检索的属性和搜索范围初始化 DirectorySearcher 类的新实例。 | 
属性
| Asynchronous | 获取或设置一个值,该值指示是否异步执行搜索。 | 
| AttributeScopeQuery | 获取或设置要在其中进行搜索的识别名特性的 LDAP 显示名称。 只有一个特性可以用于此类型的搜索。 | 
| CacheResults | 获取或设置一个值,该值指示是否在客户计算机上缓存结果。 | 
| CanRaiseEvents | 获取一个指示组件是否可以引发事件的值。(继承自 Component) | 
| ClientTimeout | 获取或设置客户端等候服务器返回结果的最长时间。 如果服务器在此时间内不响应,则中止搜索,不返回任何结果。 | 
| Container | 获取包含 IContainer 的 Component。(继承自 Component) | 
| DerefAlias | 获取或设置一个值,该值指示应如何解析搜索过程中找到的对象的别名。 | 
| DesignMode | 获取一个值,用以指示 Component 当前是否处于设计模式。(继承自 Component) | 
| DirectorySynchronization | 获取或设置表示要与搜索一起使用的目录同步控件的对象。 | 
| Events | 获取附加到此 Component 的事件处理程序的列表。(继承自 Component) | 
| ExtendedDN | 获取或设置指示识别名格式的值。 | 
| Filter | 获取或设置指示轻量目录访问协议 (LDAP) 格式筛选器字符串的值。 | 
| PageSize | 获取或设置指示分页搜索中的页大小的值。 | 
| PropertiesToLoad | 获取一个值,该值指示搜索过程中要检索的属性列表。 | 
| PropertyNamesOnly | 获取或设置一个值,该值指示搜索是否只检索已经为其赋值的特性的名称。 | 
| ReferralChasing | 获取或设置指示如何追踪转交 (Referral) 的值。 | 
| SearchRoot | 获取或设置一个值,该值指示 Active Directory 域服务层次结构中的节点,从该节点处开始搜索。 | 
| SearchScope | 获取或设置指示服务器遵循的搜索范围的值。 | 
| SecurityMasks | 获取或设置指示搜索应为指定特性返回哪些安全访问信息的值。 | 
| ServerPageTimeLimit | 获取或设置指示服务器应该搜索单页结果的最长时间的值。 这不同于整个搜索的时间限制。 | 
| ServerTimeLimit | ServerTimeLimit 属性获取或设置指示服务器在进行搜索时可花费的最长时间的值。 如果达到时间限制,则只返回在该时间之前查找到的项。 | 
| Site | (继承自 Component) | 
| SizeLimit | 获取或设置指示服务器在搜索中返回的最大对象数量的值。 | 
| Sort | 获取或设置指示对结果进行排序所依据的属性的值。 | 
| Tombstone | 获取或设置一个值,该值指示搜索是否还应返回与搜索筛选器匹配的已删除对象。 | 
| VirtualListView | 获取或设置指示搜索的虚拟列表视图选项的值。 | 
方法
| CreateObjRef(Type) | 创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。(继承自 MarshalByRefObject) | 
| Dispose() | 释放由 Component 使用的所有资源。(继承自 Component) | 
| Dispose(Boolean) | 释放由 DirectorySearcher 对象使用的托管资源,还可以选择释放非托管资源。 | 
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| FindAll() | 执行搜索并返回找到的项的集合。 | 
| FindOne() | 执行搜索并只返回找到的第一项。 | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetLifetimeService() | 
		已过时.
	 检索控制此实例的生存期策略的当前生存期服务对象。(继承自 MarshalByRefObject) | 
| GetService(Type) | 返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。(继承自 Component) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| InitializeLifetimeService() | 
		已过时.
	 获取生存期服务对象来控制此实例的生存期策略。(继承自 MarshalByRefObject) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| MemberwiseClone(Boolean) | 创建当前 MarshalByRefObject 对象的浅表副本。(继承自 MarshalByRefObject) | 
| ToString() | 返回包含 Component 的名称的 String(如果有)。 不应重写此方法。(继承自 Component) | 
事件
| Disposed | 在通过调用 Dispose() 方法释放组件时发生。(继承自 Component) |