ActiveDirectoryMembershipProvider.GetAllUsers(Int32, Int32, Int32) 方法

定义

获取 Active Directory 数据源中存储的所有用户的集合。

public:
 override System::Web::Security::MembershipUserCollection ^ GetAllUsers(int pageIndex, int pageSize, [Runtime::InteropServices::Out] int % totalRecords);
public override System.Web.Security.MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords);
override this.GetAllUsers : int * int * int -> System.Web.Security.MembershipUserCollection
Public Overrides Function GetAllUsers (pageIndex As Integer, pageSize As Integer, ByRef totalRecords As Integer) As MembershipUserCollection

参数

pageIndex
Int32

要返回的结果页的索引。 pageIndex 从零开始。

pageSize
Int32

要返回的结果页的大小。

totalRecords
Int32

当此方法返回时,此参数包含在集合中返回的记录的总数。 此参数未经初始化即被传递。

返回

一个 MembershipUserCollection,其中包含从 pageSize 所指定的页开始的 pageIndexMembershipUser 实例。

例外

pageIndex 小于 0。

- 或 -

pageSize 小于 1。

pageSizepageIndex以 、加 pageSize,减 1 大于 Int32.MaxValue

注解

此方法由 Membership 类调用,用于从 ASP.NET 应用程序的配置文件中指定的 Active Directory 数据存储中检索用户信息。

方法返回 GetAllUsers 的结果受 pageIndexpageSize 参数的约束。 参数pageSize指定要在集合中MembershipUserCollection返回的最大MembershipUser实例数。 参数 pageIndex 指定要返回的结果页,其中 0 (零) 表示第一页。

参数 totalRecords 是一个 out 参数,设置为在 Active Directory 数据存储中找到的匹配成员身份用户总数。 例如,如果配置的数据存储有 13 个用户,并且 pageIndex 值为 1,la pageSize 为 5, MembershipUserCollection 则返回的 将包含第六个到第十个用户。 参数 totalRecords 将设置为 13。

可以通过使用 enableSearchMethodsmembership Element (ASP.NET Settings Schema) 元素的 属性在应用程序的配置文件中设置 EnableSearchMethods 属性来控制是否允许搜索用户。 将 EnableSearchMethods 属性设置为 false 会导致 GetAllUsers 方法引发 NotSupportedException 异常。

提供程序使用从连接字符串中指定的搜索点开始的子树搜索。 有关连接字符串的详细信息, ActiveDirectoryMembershipProvider 请参阅类主题。

建议在确认 类发出的 ActiveDirectoryMembershipProvider 搜索查询不会对目录服务器的性能产生负面影响之前,不要在生产系统上启用搜索。 ActiveDirectoryMembershipProvider由于 类专为无状态 Web 环境设计,因此它无法使用基础 System.DirectoryServices API 公开的分页优化。 这意味着,在搜索大型目录期间执行分页操作的成本很高,应避免这样做。 搜索操作始终针对连接字符串中配置的目录服务器,或者在连接字符串指向域的情况下自动选择的服务器发出搜索操作。 提供程序不对其搜索方法使用全局编录。

适用于

另请参阅