Partilhar via


SPMember Class

Represents the base class for the SPUser and SPGroup classes.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.SPMember
    Microsoft.SharePoint.SPPrincipal
    Microsoft.SharePoint.SPRole

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<SubsetCallableTypeAttribute> _
Public MustInherit Class SPMember
'Usage
Dim instance As SPMember
[SubsetCallableTypeAttribute]
public abstract class SPMember

Remarks

Each user or group in a site has a unique member ID, has the permissions associated with that membership, and can be represented by an SPMember object. Use the Member property of the SPRoleAssignment class to get the member that represents the user or group associated with a permission.

You can use an indexer to return a specific SPUser or SPGroup object for a Web site and then assign the object to an SPMember object, as follows.

Dim site As SPWeb = 
    SPContext.Current.Site.AllWebs("Site_Name")

Dim memUser As SPMember = site.Users("User_Name")
Dim memGroup As SPMember = 
    site.Groups("Group_Name")
using(SPWeb oWebsite = SPContext.Current.Site.AllWebs["Site_Name"]);

SPMember oMemberName = oWebsite.Users["User_Name"];
SPMember oMemberGroup = oWebsite.Groups["Group_Name"];

Note

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.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPMember Members

Microsoft.SharePoint Namespace