Subscribe
E-mail
Download View Codeplex Project Site
Powered by: newtelligence dasBlog 1.9.7174.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Rich Finn
dasBlog MOSS template
Here's a cool little bit of code that keep in my common class library which I use to get all the profile values for a user and load it up into a Generic Dictionary object for retrieval.
Make sure you have a reference to Microsoft.Office.Server
public static Dictionary<string, string> GetUserInfo(string loginName, SPSite site) { Dictionary<string, string> dProfileProps = new Dictionary<string, string>(); SPSecurity.RunWithElevatedPrivileges( delegate() { using (site) { ServerContext serverContext = ServerContext.GetContext(site); UserProfileManager profileManager = new UserProfileManager(serverContext); UserProfile userProfile = profileManager.GetUserProfile(loginName); foreach (Property property in profileManager.Properties) { string userProfileValue = string.Empty; if(userProfile[property.Name].Value != null) userProfileValue = userProfile[property.Name].Value.ToString(); dProfileProps.Add(property.Name, userProfileValue); } } } ); return dProfileProps; }