The following code example uses the Users property to return the collection of users in a specified Web site of the current site collection.
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 = site.Users
Dim user As SPUser
For Each user In users
Response.Write((SPEncode.HtmlEncode(user.Name) + "<BR>"))
Next
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
SPUserCollection collUsers = oWebsite.Users;
foreach (SPUser oUser in collUsers)
{
Response.Write(SPEncode.HtmlEncode(oUser.Name) + "<BR>");
}
}