Posted: 6/3/2011
I need to access a user's profile when that user is not the current user. I have an application where one user can create an account for another user, and some of the information about the newly created user will be stored in that user's profile.
For example, user FredTucker adds user JohnSmith. I know I can access profile fields by using Context.Profile, but that returns FredTucker's profile, because he is the one logged in. How do I access JohnSmith's profile when the current user is FredTucker?
Posted: 6/4/2011
Hi there.
In one of my current projects, we were dealing with similar situation.
If you keep relation in your database between users so that you will know which user is created by which... you can simply make the following logic:
1. Create specific page where you will display the Profile for another users (don't use the same page you use for working with Profile and page for checking other's profile - for security purpose!) - lets say you have Profile.aspx for regular checking user profiles and 'OUProfile.aspx' (Other User Profile) for checking other user profile.
2. Creator user can open profile from user created by him by adding query string parameter like OUProfile.aspx?user=<username>
3. In order to prevent others to check the same profile by using query string, in Page_Load you will:
- First: Check the query string, if it doesn't exists in the correct format, automatically redirect to other page, if it exists then...- Second: Check the relation in DB between the current logged user and the one in the qurery string which the current logged in user is trying to access...
Of course, don't forget to protect this page for Logged in users only.
Hope this makes sense and will help you.
Regards,Hajan