Thursday, May 31, 2018

How to get current User's group using CSOM C#

using( ClientContext clientContext = new ClientContext("http://Server/sites/SiteCollection"));
{

  #Get Group Collection           
  GroupCollection collGroup = clientContext.Web.SiteGroups;

  clientContext.Load(collGroup);

  clientContext.Load(collGroup,
  groups => groups.Include(
  group => group.Users));

  clientContext.ExecuteQuery();

  #iterate through group            
  foreach (Group oGroup in collGroup)
   {
     UserCollection collUser = oGroup.Users;

     foreach (User oUser in collUser)
       {
         #check if user is exist or not
        }
     }
}

No comments:

Post a Comment

Server Error in '/' Application when activating "Nintex Forms" web app feature.

Apparently "INSTALL-NFService" need to be run in SharePoint PowerShell to fix this problem.   When I installed Nintex Forms agai...