kamagra how much to take

Comparing SPPrincipal Objects To See If Same Member

More because I needed to recall this method that anything. Simple helper method consuming two SPPrincpal objects to compare the membership. Simple property and type testing, nothing very fancy.

  1. public static bool SameMember(SPPrincipal x, SPPrincipal y)
  2.  
  3. {
  4.  
  5. if ((x is SPGroup) && (y is SPGroup))
  6.  
  7. {
  8.  
  9. var leftGroup = x as SPGroup;
  10.  
  11. var rightGroup = y as SPGroup;
  12.  
  13. return string.Equals(leftGroup.Name, rightGroup.Name, StringComparison.CurrentCultureIgnoreCase);
  14.  
  15. }
  16.  
  17. if (!(x is SPUser) || !(y is SPUser))
  18.  
  19. {
  20.  
  21. return false;
  22.  
  23. }
  24.  
  25. var leftUser = x as SPUser;
  26.  
  27. var rightUser = y as SPUser;
  28.  
  29. if ((!leftUser.IsDomainGroup || !rightUser.IsDomainGroup) && (leftUser.IsDomainGroup || rightUser.IsDomainGroup))
  30.  
  31. {
  32.  
  33. return false;
  34.  
  35. }
  36.  
  37. return string.Equals(leftUser.LoginName, rightUser.LoginName, StringComparison.CurrentCultureIgnoreCase);
  38.  
  39. }
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>