SPGroup.RemoveUser method
SharePoint 2013
Removes the specified user from the group.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Parameters
- user
- Type: Microsoft.SharePoint.SPUser
The user to be removed from the group.
The following code example removes a specified user from every group in a site collection.
using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb) { SPGroupCollection collGroups = oWebsiteRoot.SiteGroups; SPUser oUser = oWebsiteRoot.Users["User_Name"]; foreach (SPGroup oGroup in collGroups) { oGroup.RemoveUser(oUser); } }
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. |
Note