Is it possible to get two User Profiles service application

  • 1). User profile service1
  • 2). User profile service2

I have some code which only fetches the Ist User profile service application but not the second one. How can I access the 2nd User profile Service application using code?

SPServiceContext oServiceContext = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);
UserProfileManager oProfileManager = new UserProfileManager(oServiceContext);

Note: For some reason both User Profiles Service applications are provision on same SharePoint farm.

Note: No out of the box sync is used for User profiles.

  • Why would you want two? Should the run on different servers?
    – Benny Skogberg
    Commented Dec 11, 2012 at 14:51
  • It's a requirement for the client to have the two user profiles on same SharePoint farm.
    – Geek
    Commented Dec 11, 2012 at 14:53
  • Note: no out of the box sync is used for User profiles.
    – Geek
    Commented Dec 11, 2012 at 14:54
  • Note: no out of the box sync is used for User propfiles.
    – Geek
    Commented Dec 11, 2012 at 14:54

3 Answers 3


If you are having two User profile aervice applications in your farm then you need to create one custom connection group for each Web application in the farm. Then, you can change the each User profile service application to be associated with different Web application. It can be done by changing the service applications that are included in the Default service application connection group. In the code, use url of each Web application to get UserProfileManager of each User profile service application

  • It's rather proxy group that is attached to the Web Application, and this is how availability of different Service Applications in Web Application is managed. Commented Dec 14, 2012 at 11:58
  • I did this scenario a long time ago. Thanks for correction Commented Jan 6, 2013 at 16:58

Though I agree that having 2 user profile services on a farm is a little nutty, hopefully your site only has 1 associated with it. You can GetContext on a SPSite object, instead of Default, which should get you the UPS associated to that site. If there's 2 associated... well... I'll have to dig in some more. Let me know if this works.

  • appreciate your help!
    – Geek
    Commented Dec 14, 2012 at 8:43

User Profile Service application will have it's proxy. This will let you distinguish these two services. Assign each proxy to a different proxy group (one could stay in the default group) and second you could assign to 'MyCustomGroup'. This is how you can create it.

New-SPServiceApplicationProxyGroup –Name MyCustomGroup

Now you can go to Central Administration->Application Management->Configure service application associations and assign your new proxy group to the web application. Assign one of the User Profile Service applications proxies to it. And now you are ready to roll.

And this is how you can retrieve Service application context using custom proxy group name.

 SPServiceApplicationProxyGroup applicationProxyGroup =   SPFarm.Local.ServiceApplicationProxyGroups["MyCustomGroup"];
 SPServiceContext serviceContext = SPServiceContext.GetContext(applicationProxyGroup, SPSiteSubscriptionIdentifier.Default);

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.