zoukankan      html  css  js  c++  java
  • 在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();

                }

            }
  • 相关阅读:
    2014 ACM/ICPC Asia Regional Guangzhou Online HDU 5024 Wang Xifeng's Little Plot
    HDU 5015 2014 ACM/ICPC Asia Regional Xi'an Online 233 Matrix
    POJ 1269 Intersecting Lines(直线相交的判断)
    POJ 3304 Segments
    POJ 2318 TOYS
    The 2014 ACM-ICPC Asia Mudanjiang Regional First Round C ZOj 3811
    unique函数(先记下来)
    计算几何常用算法(数学知识)
    HUD 3461 codelock 纯题意解释,不含思想
    POJ 1182 食物链
  • 原文地址:https://www.cnblogs.com/wengnet/p/1442724.html
Copyright © 2011-2022 走看看