Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

Thanks

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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); 
context.Load(membersGroup.Users); 
context.ExecuteQuery(); 

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"
     ProductID="{4a07f3bd-803d-45f2-a710-b9e944c3396e}"
     Version="1.0.0.0"
     SharePointMinVersion="15.0.0.0"
     Name="MySampleApp"
>
  ...

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

Reference: App permissions in SharePoint 2013

share|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
add comment

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,

Dan

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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