kamagra how much to take

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:

  1. private void RemoveCurrentUserFromGroup(SPGroup group)
  2. {
  3. SPUser curUser = SPContext.Current.Web.CurrentUser;
  4. if (group.ExplicitlyContainsCurrentUser)
  5. {
  6. group.Users.Remove(curUser.LoginName);
  7. }
  8. }
Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>