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();  
    •   
    •          }  
    •   
    •      } 
  • 相关阅读:
    Java知识体系之基础知识
    002-JavaNIO
    001-四种常见的IO模型
    c/c++面试题(6)运算符重载详解
    c/c++面试题(5)(c++重要的概念详解)
    c/c++面试题(4)字符串翻转/打印任意进制格式/类型转换
    c/c++面试题(3)strcat/strcmp/strlen/strcpy的实现
    c/c++面试题(2)
    c/c++面试题(1)
    cocos2dx 3.0 之 lua 创建类 (二)
  • 原文地址:https://www.cnblogs.com/TNSSTAR/p/2932819.html
Copyright © 2011-2022 走看看