1

I'd like to be able to programmatically retrieve a user's name and manager using code similar to the following:

    using (var clientContext = TokenHelper.GetClientContextWithAccessToken(hostWeb.ToString(), accessToken))
    {
        var peopleManager = new PeopleManager(clientContext);
        var personProperties = peopleManager.GetPropertiesFor(loginName);
        clientContext.Load(personProperties);
        clientContext.ExecuteQuery();
        property = personProperties.UserProfileProperties[requestedProperty].ToString();
        return property;
    }

On an app without the User Profiles (Social) permission, I get an Access Denied on the ExecuteQuery(). I assume you need the User Profiles (Social) | Read permission on the app to be able to do this. I attempted to side-load an app with this permission on a dev site and was told I needed to be a Tenant Administrator which now has me doubting whether this permission is valid for a store-based app.

Is it possible to access user data such as PreferredName and Manager using the PeopleManager in an app on the SharePoint AppStore? If not, is it possible to access this data in a non-interactive fashion using Microsoft Graph?

Ryan Shripat
  • 5,574
  • 6
  • 49
  • 77

1 Answers1

0

You can get this data using the Microsoft Graph, with simple queries like https://graph.microsoft.com/v1.0/me to get the current user profile and https://graph.microsoft.com/v1.0/me/manager to get the manager. You can find a code sample of the Microsoft Graph .Net SDK here: https://github.com/microsoftgraph/aspnet-snippets-sample

Yina - MSFT
  • 1,756
  • 1
  • 12
  • 10
  • Getting properties like /me and /me/manager imply an interactive logon process. I need to get at user data (manager, full name) without the user having to login. I've been through that GitHub project already, but it does not provide a way to get at this data without a user logging in, as far as I can tell. – Ryan Shripat Oct 07 '16 at 12:39