I am trying to get a user's manager with this code:

  SPSite site = new SPSite(SPContext.Current.Site.Url);
  SPServiceContext context = SPServiceContext.GetContext(site);
  UserProfileManager profileManager = new UserProfileManager(context);
  //Note that I have an SPUser object, user, previously defined.
  UserProfile userProfile = profileManager.GetUserProfile(user.ID);
  UserProfile managerProfile = userProfile.GetManager();

My problem is that I am getting a null UserProfileManager. I suspect it's because the SPServiceContext has a SiteSubcriptionId of {00000000-0000-0000-0000-000000000000}.

I am debugging this on my local SharePoint server. I am running it on a development environment on Windows 7. Does this error indicate a problem with my environment?

Is there a better way to get the manager of a given SPUser?


It appears neither my local machine or my test server has the User Profile Service set up properly. So that is probably why it's not working. I'm going to attempt to get that working and see if I still have the problem.

  • What if you moved all but the last two "UserProfile" lines out of the delegate? Dec 3, 2012 at 19:17
  • The same thing happens if I move all but the last two "UserProfile" lines out of the delegate.
    – Jeremy
    Dec 3, 2012 at 19:22

2 Answers 2


The empty Guid here actually is not concerning. The SiteSubscriptionId will always be a blank Guid unless you have multi-tenancy enabled in your environment.

Enabling Multi Tenant Support in SharePoint 2010

You may need to add permission for your user on the User Profile Service Application.

In Configure User Profile sync connections they were trying to get the UserProfileManager via PowerShell and getting an error (NullReferenceException) but resolved it by ensuring the user account attempting to get the UserProfileManager had permissions:

1) As a administrator with full control

2) connection permissions as full control

Then you have access to the connection manager and can programatically access the connections.

  • I am still getting a SPServiceContext with a SiteSubcriptionId of {00000000-0000-0000-0000-000000000000}, causing a null UserProfileManager. I tried moving the first three lines out of the delegate, and the same thing happens.
    – Jeremy
    Dec 3, 2012 at 19:14
  • Just saw your link. I am checking that out now...
    – Jeremy
    Dec 3, 2012 at 19:22

In addition to the Administrator and Permission on the UPSA, I needed to add the SharePoint setup user as db_owner on the ProfileDB.

Your Answer

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

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