14 December 2010

To get Users list from the MOSS

//Write this code

 

SPSite mySite = new SPSite("http://amu-sp:31273/amu2");

            SPWeb web = mySite.OpenWeb();

 

           

            ServerContext context = Microsoft.Office.Server.ServerContext.GetContext(new SPSite("http://amu-sp:31273/amu2"));

            UserProfileManager upm = new Microsoft.Office.Server.UserProfiles.UserProfileManager(context);

           // UserProfile user=upm.GetUserProfile(

 

 

            foreach (UserProfile user in upm)

            {

               

               // Console.WriteLine(user[PropertyConstants.UserName]+":");

                if (user[PropertyConstants.WorkEmail] !=null)

                {

                    Console.WriteLine(user[PropertyConstants.WorkEmail]);

                }

            }