RealActivity is a specialized healthcare services and solution advisory firm.

A keystone to social computing using the Microsoft stack

The user profile database in SharePoint is a keystone to social computing using the Microsoft stack. We store information about users in our organization, communities or members of external sites in the user profile database.

Keystone to social using MS

Earlier today I was asked for sample code to access the user store. I often use the code below in presentations to demonstrate how we programmatically access information about users in the profile store. If we need to access user profiles from external applications we should use the SharePoint web services.

namespace UserProfilesSample 


    class Program 


        static void Main(string[] args) 



            using (SPSite site = new SPSite("http://SharePoint2007")) 


                ServerContext context = 


                UserProfileManager profileManager = new UserProfileManager(context); 


                string userName = @"MyDomain\Administrator"; 

                Console.WriteLine("All Profiles:"); 

                foreach (UserProfile p in profileManager) 


                    Console.WriteLine("{0} : {1}", p.ID, p.MultiloginAccounts[0]); 



                if (profileManager.UserExists(userName)) 


                    UserProfile profile = profileManager.GetUserProfile(userName);                 

                    Console.WriteLine("Found User Profile {0}", profile.ID); 

                    Console.WriteLine("\tPersonal Site: {0} ({1})", 






                    Console.WriteLine("No account found for " + userName); 












Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: