• 在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();

                }

            }
  • 相关阅读:
    Windows 下Nexus搭建Maven私服
    WebService中获取request对象一例
    利用window.navigator.userAgent判断当前是否微信内置浏览器
    批量插入写法
    MySql 使用递归函数时遇到的级联删除问题
    【Mysql】 你会用 information_schema吗?
    Volatile 多线程中用到的关键字
    spring+springMVC中使用@Transcational方式管理事务的必须要配的东西。
    Android中操作SQLite数据库
    Oracle中的字符处理方法
  • 原文地址:https://www.cnblogs.com/wengnet/p/1442724.html
Copyright © 2020-2023  润新知