checking that user belongs to particular Group are Not

it is used to find the current loged in user belongs to 1 particular group are not...  
private bool CheckKaizenMentor(string groupName) 
        { 
            bool userVal = false; 
            SPSecurity.RunWithElevatedPrivileges(delegate() 
              { 
                  using (SPSite site = new SPSite(SPContext.Current.Site.Url)) 
                  { 
                      using (SPWeb web = site.OpenWeb()) 
                      { 
                          //For getting the Group Users for Kaizen mentor radio button list. 
                          SPGroup kcUsers = web.Groups[groupName]; 
                          foreach (SPUser user in kcUsers.Users) 
                          { 
                              if (currentUser == user.LoginName) 
                              { 
                                  userVal = true; 
                                  break; 
                              } 
                          } 
                      } 
                  } 
              }); 
  
            return userVal; 
        } 

Comments

Popular posts from this blog

My Interview Experience

React Checkbox Control SPFx