Do you need to get the owner of the user profile in SharePoint to conditionally display sensitive data? If yes, then read on... (Tip from colleague Kiran Bellala)
ProfilePropertyLoader.GetPageProfile method can return the user profile associated with the page.
(http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.portal.webcontrols.profilepropertyloader.getpageprofile.aspx)
UserProfile thisPageUserProfile = ProfilePropertyLoader.GetPageProfile(this.Page); string thisPageAcctName = thisPageUserProfile["AccountName"].Value.ToString(); string loggedinUserAcctName = HttpContext.Current.User.Identity.Name; if (thisPageAcctName.Equals(loggedinUserAcctName)) { Label1.Text = "This is my user profile"; } else { //this is not my user profile. hide the web part this.Hidden = true; }Keywords: SharePoint User Profile
0 comments:
Post a Comment
I always welcome feedback from my readers.