SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
What if you moved all but the last two "UserProfile" lines out of the delegate? – John Chapman Dec 3 '12 at 19:17
The same thing happens if I move all but the last two "UserProfile" lines out of the delegate. – Jeremy Dec 3 '12 at 19:22
up vote 4 down vote accepted

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.

share|improve this answer
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 '12 at 19:14
Just saw your link. I am checking that out now... – Jeremy Dec 3 '12 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.

share|improve this answer

Your Answer


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.