3

my scenario : i tried the GetGroupByName method but didnt work,it cant find the group, i am not able to find the id of the group also.

 GroupCollection groupColl = clientContext.Web.SiteGroups;
                Group newgroup = clientContext.Web.SiteGroups.GetByName("InternalUsers");
                clientContext.Load(groupColl);
                clientContext.ExecuteQuery();
5
  • can you please share the code that you have tried ? Commented Sep 14, 2017 at 11:40
  • @GautamSheth i edited the question Commented Sep 14, 2017 at 11:42
  • I think you need to change it to clientContext.Load(newgroup);. Also ensure that you are passing the correct group name. Commented Sep 14, 2017 at 11:46
  • @GautamSheth didnt work,note that this group was created on azure,am being told it a domain group Commented Sep 14, 2017 at 12:02
  • its needs to be a sharepoint group. Commented Sep 14, 2017 at 12:56

1 Answer 1

4

Try this code below :

GroupCollection groupColl = clientContext.Web.SiteGroups;
Group newgroup = groupColl.GetByName("InternalUsers");
clientContext.Load(newgroup);
clientContext.ExecuteQuery();
2
  • didnt work, i am being told the group is a domain group Commented Sep 14, 2017 at 12:01
  • The above code actually works for SharePoint Groups. Domain groups are treated differently and you'd have to crack open your domain group using Active Directory APIs. Per the error message, the Group name you used is NOT a SharePoint group, but an AD group. As such, SharePoint cannot return anything because even if it had the AD group object, it would be a type mismatch when returned since GetByName() is expected to return a SharePoint Group. Commented Sep 25, 2018 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.