I'm creating web part that will show user's links and sites. When I'm trying to get context from SPServiceContext information server throws me exception:

No User Profile Application available to service the request. Contact your farm administrator...

This is my code:

    using (SPSite site = new SPSite(SPContext.Current.Site.ID))
        SPServiceContext context = SPServiceContext.GetContext(site);
        UserProfileManager mgr = new UserProfileManager(context);
        UserProfile userProfile = mgr.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);

I have checked that "User Profile Service Application" is started. What I'm missing? How to collect user profile details?


  • Did you create a user profile service app and started it on one server in the farm? Check Spence blog if you don't know: harbar.net/articles/sp2010ups.aspx Feb 1, 2013 at 9:44
  • Yes, User Profile Service is started. User Profile Synchronization Service has status "starting" all the time.
    – Neon
    Feb 1, 2013 at 9:49
  • I'm not 100% sure if this "stuck on starging" is a problem. Not sure if the code should run because this is only the ad sync. but i'm not 100% sure. maybe it is better to first get this thing up and running. check spence harbars blog is has many solutions to the stuck in starting problem. Feb 1, 2013 at 12:37

4 Answers 4


If UPS is configured and started please check the permissions on the UPS application. As you run with elevated privileges you are using the app pool account of the web app your are hosted on. This account should have permissions for the user profile service app.

Check out this blog post to see the process of configuring permissions (not administrator permissions):


For a full reference of the user profile service check out this technet article:


  • I have added my account to admin list for user profile service. Nothing has changed. When I click on User Profile Service link, I'm getting exception window. I'm not able to open configuration site for this service.
    – Neon
    Feb 1, 2013 at 10:06
  • Thats not what i told you to do :-) check the app pool account the web app is running. add this account not to the admin permissions add the accounut to the permissions (check the blog post). If you add a user to the admin permissions you grant them administration rights and not the right to use the service app. Thats the concept behind it. Check your app pool account and grant him full control. The user executing the browser can be ignored. Feb 1, 2013 at 12:43

The reason can be that User Profile Service is not associated with the Webapplication. This can be checked by going into CA-->Application Management-->WebApplications--> Select your web application. In the ribbon Select Service Connections. In Configure Service Applications popup ensure that User Profile Service Application is checked.


It sounds like you are on the right track and have done all the correct things. I remember Todd Klindt talking about the User Profile Service Instance saying that it was started even when it wasn't in one of his netcasts.

Check that the SharePoint Administration Service is running on the SharePoint machine running User Profile Service.

Try restarting the Service Instance on the machine that is running User Profile Service, you could use SharePoint Management Console and PowerShell to do this:-

`$serviceInstance = Get-spserviceinstance | ?{$_.TypeName -like "User Profile Service"};

Stop-SPServiceInstance -Identity $serviceInstance;

Start-SPServiceInstance -Identity $serviceInstance; `

Now see if you can now access the User Profile Service Application.





If all you are doing is displaying profile information for the current user, then there is no need to elevate permissions here. The current user already has permissions to get their own data.

ProfileLoader loader = ProfileLoader.GetProfileLoader(SPServiceContext.Current);
UserProfileManager manager = loader.GetUserProfileManager();
UserProfile profile = manager.GetUserProfile(true);

The GetUserProfile(bool) method gets you the current user's profile to work with, if you pass true, it creates the profile if it doesn't exist.

In general, RunWithElevatedPriveleges and the UserProfileManager do not play well together. UserProfileManager does not support impersonation/elevation.

If you use the ProfileLoader, you will also take advantage of reusing the UserProfileManager that may have been gotten by other web controls already, and so can make your code more performant.

And BTW - the UserProfileSynchronization service would have nothing whatsoever to do with this. That only deals with AD import/export.

Your Answer

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

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