Here is a weird situation. The site works with forms based authentication. I need to get the activity feed of the current user. As you know in FBA mode login names are prefixed with i:0#.f|provider_name. For an ActivityManager, you need a user profile. For a user profile you need a Windows login name. For that I used SPClaimProviderManager and turned that FBA login name into a Windows login name and successfully instantiated an ActivityManager. But guess what, ActivityManager uses HttpContext.Current.User.Identity.Name in its GetActivitiesForMe method, so when I call it I get a UserNotFound exception.

What should I do?

  • Can you please provide your code fragment, which is described in the question? May 15, 2011 at 19:22

2 Answers 2

  1. Have you tried new ActivityManager().GetActivitiesByUser(profile)?

  2. Have you tried your code with different users? Don't you use SharePoint application pool account? UserNotFoundException often refers to non-existant SHAREPOINT\system account.

I've explored the source code of Microsoft.Office.Server.UserProfiles.dll, and found that if you instantiate the ActivityManager class with correct UserProfile object, all should work right.

HttpContext.Current.User.Identity.Name is used from EnsureViewerInfo private method only if you instantiate ActivityManager using default constructor.

  • I am trying to get the feed for a specific user (current logged on user in this case). What I need is a method like .GetActivitiesForUser(profile). May 15, 2011 at 16:39

Try to instantiate the ActivityManager with the UserProfile of the current user.

string sAccount = SPContext.Current.Web.CurrentUser.LoginName;
SPServiceContext serviceContext = SPServiceContext.GetContext(SPContext.Current.Site); 
UserProfileManager upm = new UserProfileManager(serviceContext); 
if (!upm.UserExists(sAccount)) upm.CreateUserProfile(sAccount);  
UserProfile u = upm.GetUserProfile(sAccount); 
ActivityManager am = ActivityManager(u, serviceContext);

As an alternative, you could look into the ActivityFeed.aspx application page. It will return the activities in a RSS feed:


  • Matt, I am using exactly the same code with you. But the problem is, if you call AcitivtyManager.GetActivitiesForMe(), it doesn't look at the userprofile you create. It uses HttpContext.Current.User.Identity (verified with Reflector). So even if you create the ActivityManager with a UserProfile, that UserProfile is not used when you call GetActivitiesForMe method. This is a design flaw I think. May 16, 2011 at 10:59
  • I looked through the ActivityManager with Reflector and I can't seem to find where it uses "HttpContext.Current.User.Identity". GetActivitiesForMe() creates and return this collection: "ActivityEventsCollection(this, this.m_CurrentUserId, true, minEventTime, maxEvents, asSeenBy, true)". m_CurrentUserId is set by the constructor and pulled from the user profile you pass to the constructor. May 16, 2011 at 14:05
  • Are your FBA users able to view their My Sites? There may be some issue with FBA users even being able to have My Sites. May 16, 2011 at 14:28

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.