Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Problem accessing My Sites user profiles anonymously

  Asked By: Ashu    Date: Jan 01    Category: Sharepoint    Views: 3799

From a public web site site collection, we are trying to access user
profiles in a separate My Sites site collection. When accessing them
anonymously, running the code in an RunWithElevatedPrivileges block I'm
getting an authentication error. When I login to the public site (I'm
an admin) it returns just fine.

A code excerpt is below:

protected override void CreateChildControls()
//Get the current Site
//Get current Level
SPContext spContext = SPContext.Current;

using (SPSite currentSite = new
using (SPWeb currentWeb =
SPWeb rootweb = currentSite.RootWeb;
ServerContext context =
UserProfileManager profileManager = new


// this line errors with
// The user could not be authenticated to
the Web site being accessed
profile =



2 Answers Found

Answer #1    Answered By: Stephon Valentine     Answered On: Jan 01

Running code  with elevated priveledges runs the code in the context  of
the App Pool Identity account. Since mysites are normally in a separate
appPool does the Apppool Identity of the site  where you are running  the
code have access  rights in the MySites AppPool?

Answer #2    Answered By: Leif Cardenas     Answered On: Jan 01

The main web  site is at
http://webapp.domain.com and the my sites  is at
http://webapp.domain.com/mysites, so they are sharing the same
application pool.

I noticed the behavior a little higher up in the profileManager, which
is throwing an authorization exception in some of it's properties after
it's created (specifically Count and UserProfileChangeJobSchedule).

Didn't find what you were looking for? Find more on Problem accessing My Sites user profiles anonymously Or get search suggestion and latest updates.