zoukankan      html  css  js  c++  java
  • sharepoint2010 UserProfileManager使用注意事项22

    • class Program  
    •   
    •  {  
    •   
    •      static void Main(string[] args)  
    •   
    •      {  
    •   
    •          try  
    •   
    •          {  
    •   
    •              using (SPSite site = new SPSite("http://ianzhang/"))  
    •   
    •              {  
    •   
    •   
    •   
    •                  ServerContext context = ServerContext.GetContext(site);  
    •   
    •                  UserProfileManager profileManager = new UserProfileManager(context);  
    •   
    •                  if (profileManager.UserExists(site.OpenWeb().CurrentUser.LoginName))  
    •   
    •                  {  
    •   
    •                      UserProfile user1 = profileManager.GetUserProfile(@"ianzhang/administrator");  
    •   
    •                      Console.WriteLine("Profile {0}", user1.MultiloginAccounts[0]);  
    •   
    •                      foreach (Property prop in profileManager.Properties)  
    •   
    •                      {  
    •   
    •                          Console.WriteLine("/t{0} : {1}", prop.DisplayName, RenderProperty(user1, prop));  
    •   
    •                      }  
    •   
    •                  }  
    •   
    •              }  
    •   
    •          }  
    •   
    •          catch (Exception ex)  
    •   
    •          {  
    •   
    •              Console.WriteLine(ex.Message);  
    •   
    •          }  
    •   
    •   
    •   
    •          Console.ReadLine();  
    •   
    •      }  
    •   
    •   
    •   
    •      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();  
    •   
    •          }  
    •   
    •      } 
  • 相关阅读:
    2017.0321.数字电路与系统-触发器
    2017.0320.数字电路与系统-触发器
    2017.0319.数字电路与系统-算术逻辑单元
    2017.0317.数字电路与系统-减法器
    2017.0316.算术运算电路和ALU
    2017.0315.数字电路与系统-奇偶校验器
    2017.0313.数字电路与系统-数据选择器分配器的理解
    2017.0311.数字电路与系统-数据选择器分配器的理解
    2017.0310.数字电路与系统-数据选择器分配器的理解
    2017.0309.数字电路与系统-组合电路的模块分析
  • 原文地址:https://www.cnblogs.com/TNSSTAR/p/2932819.html
Copyright © 2011-2022 走看看