SPWeb.SiteUsers 属性
Gets the collection of all users that belong to the site collection.
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public ReadOnly Property SiteUsers As SPUserCollection
Get
用法
Dim instance As SPWeb
Dim value As SPUserCollection
value = instance.SiteUsers
public SPUserCollection SiteUsers { get; }
属性值
类型:Microsoft.SharePoint.SPUserCollection
An SPUserCollection object that represents the users.
示例
The following code example uses the SiteUsers property to return the collection of users for the current site collection and the user display names
This example requires using directives (Imports in Microsoft Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.
Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website_URL")
Dim users As SPUserCollection = webSite.SiteUsers
For Each user As SPUser In users
Response.Write((SPEncode.HtmlEncode(user.Name) + "<BR>"))
Next
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
SPUserCollection collUsers = oWebsite.SiteUsers;
foreach (SPUser oUser in collUsers)
{
Response.Write(SPEncode.HtmlEncode(oUser.Name) + "<BR>");
}
}
备注
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.