SharePoint Security Tip: ExplicitlyContainsCurrentUser
When doing security programming, often times you will often run into group chaining, essentially this is when the current SPUser object is a member of a SPGroup through indirect association. However, often times the software requirement will be targeted to direct SPUser group membership, i.e. a user is an EXPLICIT member of a group, and not in a SPGroup which is nested in a parent SPGroup.
Within code, the use is pretty straightforward:
-
private void RemoveCurrentUserFromGroup(SPGroup group)
-
{
-
SPUser curUser = SPContext.Current.Web.CurrentUser;
-
if (group.ExplicitlyContainsCurrentUser)
-
{
-
group.Users.Remove(curUser.LoginName);
-
}
-
}
3 Comments »
RSS feed for comments on this post. TrackBack URL





















Articles & Research
SharePoint Architecture
Personal/Off-Topic
Latest Free SharePoint Software
SecureCenter For SharePoint
SharePoint Security Assurance Program™
Free Online SharePoint Security Tools
Online SharePoint Security Health Assessment
Article Or Research Filed Under 
.
Comment by . — December 17, 2008 @ 10:23 am
ohhhh, OP is from Defense Logistics Agency….I am guessing Kirk?
Comment by Adam Buenz — December 17, 2008 @ 10:55 am
[...] http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-security-tip-explicitlycontainscurrentuser/ [...]
Pingback by SharePoint Security Tip- SPuser and SPGroups, ExplicitlyContainsCurrentUser « Marty’s Scribbles — December 19, 2008 @ 5:46 am