江湖路
专注AJAX和Moss

 

static void Main(string[] args)
        {
            
using (SPSite site = new SPSite("http://moss:800"))
            {

                ServerContext context 
= ServerContext.GetContext(site);

                UserProfileManager profileManager 
= new UserProfileManager(context);

                UserProfile user1 
= profileManager.GetUserProfile(@"AW\Administrator");

                Console.WriteLine(
"Profile {0}", user1.MultiloginAccounts[0]);

                
foreach (Property prop in profileManager.Properties)
                {

                    Console.WriteLine(
"\t{0} : {1}", prop.DisplayName, RenderProperty(user1, prop));

                }

                Console.ReadLine();

            }


            Console.ReadKey();
        }

        
static string RenderProperty(UserProfile profile, Property prop)
        {

            UserProfileValueCollection values 
= profile[prop.Name];

            
if (values.Value == null)

                
return "(NULL)";

            
if (prop.IsMultivalued)
            {

                StringBuilder sb 
= new StringBuilder();

                
foreach (object o in values)
                {

                    sb.AppendFormat(
"{0} ", o);

                }

                
return sb.ToString();

            }

            
else
            {

                
return values.ToString();

            }

        }
posted on 2009-04-24 10:27  wengnet  阅读(510)  评论(1编辑  收藏  举报