Posted By

scholli on 10/27/10


Tagged

security sharepoint


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Tyster
iabidi


Check if user is member of a SharePoint group


 / Published in: C#
 

  1. public static class SecurityHelper
  2. {
  3. public static bool IsUserMemberOfGroup(SPUser user, string groupName)
  4. {
  5. bool result = false;
  6.  
  7. if (!String.IsNullOrEmpty(groupName) && user != null)
  8. {
  9. foreach (SPGroup group in user.Groups)
  10. {
  11. if (group.Name == groupName)
  12. {
  13. // found it
  14. result = true;
  15. break;
  16. }
  17. }
  18. }
  19.  
  20. return result;
  21. }
  22. }

Report this snippet  

You need to login to post a comment.