How can I allow users to view the users in a sharepoint group? Currently if I try to query users in the site groups using the client object model I get an unauthorized exception.

For example, if I am manager Bob, I want to view the group DBA's, and find out if Bill is in that group.



It looks possible:

You can use the SharePoint .NET Framework CSOM to manage SharePoint users, groups, and user security.

Retrieve all users in a SharePoint group

This example retrieves information about all users from a SharePoint group named Members.

// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://SiteUrl"); 

GroupCollection siteGroups = context.Web.SiteGroups; 

// Assume that there is a "Members" group, and the ID=5. 
Group membersGroup = siteGroups.GetById(5); 

foreach (User member in membersGroup.Users) 
    // We have all the user info. For example, Title. 
    label1.Text = label1.Text + ", " + member.Title; 

Reference: How to: Complete basic operations using SharePoint 2013 client library code

If you still get an Access Denied, take a look at the AppManifest.xml and update you permissions for the app:

<?xml version="1.0" encoding="utf-8" ?>
<App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest"

    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="Read"/>

Reference: App permissions in SharePoint 2013

| improve this answer | |
  • Thanks Benny for your response. That exact query will return "Access denied. You do not have permission to perform this action or access this resource." How can I get permission for all or some users? – Steve Apr 30 '13 at 22:50
  • @Steve You're Welcome! I'm thinking it has to do with permission level. Have you set it in the AppManifest.xml? – Benny Skogberg May 1 '13 at 4:29
  • An AppManifest.xml is new to me. So far my client app has functioned without one (I pass user credentials in to the ClientContext and that has allowed me to access all that I've needed (until now)). It sounds like I need to do some reading to see how to implement an app policy? – Steve May 1 '13 at 23:00

I know I may be too late, but I have had the exact same issue you did.

After hours of testing different stuff, I wondered in SharePoint Central Administration and found the solution.

You have to go to the central administration - > application management-> manage web applications , chose the application, click on User Policy (in the ribbon )and add the user you want with Full Read Permissions.

Also don't forget about the ClientContext Credentials.

Hope it helps,


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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