I'm getting Windows users' profiles, in my webpart, doing the following:

UserProfileManager pm = new UserProfileManager(SPServiceContext.Current);
SPUser spuser = web.AllUsers.GetByID(user.Id);
UserProfile up = pm.GetUserProfile(spuser.LoginName);

When it comes to a FBA user, the second line will raise an exception. So, I guess there's another way to get FBA users' profile. Could anyone tell me how to do it?


  • which exception?
    – Steve B
    Commented Jun 21, 2012 at 20:13

2 Answers 2


Hi did you get anywhere with this? I have a similar problem, where the profile hasn't been created yet for the fba user so I'm trying to create it in code at the user creation level, but having no such luck. I've written a more complete post at: FBA User Profile Creation Access Denied

If anyone can help, that would be ace.

thanks, Bav


What is the user object? How is that loaded?

Instead of web.AllUsers.GetById, try web.SiteUsers.GetById. This will include all users in the site collection.

  • I get the user object from a parallel database (not the SharePoint one). Commented Feb 14, 2012 at 13:02
  • and user.id is their SharePoint ID, i.e. 1, 2, 32, 100? Commented Feb 14, 2012 at 13:19
  • Exactly. Anyway, I'm getting the same error doing what you suggested :S Commented Feb 15, 2012 at 23:20
  • What's the error message? Do you have anonymous access enabled? Commented Feb 16, 2012 at 1:16
  • I also wonder if you can use SPServiceContext.Current, since you're not running in context as I understand. Would be better if you could post the entire code snippet.
    – Jasper
    Commented Apr 19, 2012 at 15:31

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.