zoukankan      html  css  js  c++  java
  • sharepoint2010 userprofileManager1

    2012-11-29 17:09

    sharepoint 获取userprofileManager中用户详细信息

    using (SPSite spSite = new SPSite(siteUrl))
                {
                    DataTable usersDT = new DataTable();
                    //用户名
                    usersDT.Columns.Add("UserName", typeof(string));
                    //描述
                    usersDT.Columns.Add("AboutMe", typeof(string));
                    //专业领域
                    usersDT.Columns.Add("Responsibility", typeof(string));
                    //移动电话
                    usersDT.Columns.Add("CellPhone", typeof(string));
                    //传真
                    usersDT.Columns.Add("Fax", typeof(string));
                    //住宅电话
                    usersDT.Columns.Add("HomePhone", typeof(string));
                    //办公电话
                    usersDT.Columns.Add("Office", typeof(string));
                    //助手
                    usersDT.Columns.Add("Assistant", typeof(string));
                    //参与的项目
                    usersDT.Columns.Add("PastProjects", typeof(string));
                    //技能
                    usersDT.Columns.Add("Skills", typeof(string));
                    //学校
                    usersDT.Columns.Add("School", typeof(string));
                    //生日
                    usersDT.Columns.Add("Birthday", typeof(string));
                    //兴趣
                    usersDT.Columns.Add("Interests", typeof(string));
                    //公作电子邮件
                    usersDT.Columns.Add("WorkEmail", typeof(string));
                    //部门
                    usersDT.Columns.Add("Department", typeof(string));
                    //职务
                    usersDT.Columns.Add("Title", typeof(string)); 

                    SPServiceContext serviceContext = SPServiceContext.GetContext(spSite);
                    //initialize user profile config manager object
                    UserProfileManager upm = new UserProfileManager(serviceContext);

                    string accountName = "";
                    if (Request.QueryString["accountname"] != null)
                    {
                        //获取呗查看用户名
                        accountName = Request.QueryString["accountname"].ToString();
                    }else{
                        //获取当前登录用户名
                        accountName= SPContext.Current.Web.CurrentUser.LoginName;
                    }
                    //获取用的详细配置信息
                    UserProfile u = upm.GetUserProfile(accountName);
                    //创建dataRow实例
                    DataRow dr = usersDT.NewRow();
                    if (u[PropertyConstants.PictureUrl].Value != null)
                    {
                        dr["userImageUrl"] = u[PropertyConstants.PictureUrl].Value.ToString();
                    }
                    else
                    {
                        dr["userImageUrl"] = "/_layouts/images/person.gif";
                    }
                    dr["userName"] = u[PropertyConstants.FirstName].Value.ToString();
                    dr["AboutMe"] = u[PropertyConstants.AboutMe].Value.ToString();
                    dr["Responsibility"] = u[PropertyConstants.Responsibility].Value.ToString();
                    dr["CellPhone"] = u[PropertyConstants.CellPhone].Value.ToString();
                    dr["Fax"] = u[PropertyConstants.Fax].Value.ToString();
                    dr["HomePhone"] = u[PropertyConstants.HomePhone].Value.ToString();
                    dr["Office"] = u[PropertyConstants.Office].Value.ToString();
                    dr["Assistant"] = u[PropertyConstants.Assistant].Value.ToString();
                    dr["PastProjects"] = u[PropertyConstants.PastProjects].Value.ToString();
                    dr["Skills"] = u[PropertyConstants.Skills].Value.ToString();
                    dr["School"] = u[PropertyConstants.School].Value.ToString();
                    dr["Birthday"] = u[PropertyConstants.Birthday].Value.ToString();
                    dr["Interests"] = u[PropertyConstants.Interests].Value.ToString();
                    dr["WorkEmail"] = u[PropertyConstants.WorkEmail].Value.ToString();
                    dr["Department"] = u[PropertyConstants.Department].Value.ToString();
                    dr["Title"] = u[PropertyConstants.Title].Value.ToString();
                    usersDT.Rows.Add(dr);
                }

  • 相关阅读:
    【Hadoop】MapReduce自定义分区Partition输出各运营商的手机号码
    【Hadoop】Hadoop的数据压缩方式
    【Java】生成随机的手机号码并输出到文件
    【Java】递归删除目录以及文件
    【Hadoop】单机、伪分布式、完全分布式集群搭建
    【Linux】常用基础命令
    【Web】jquery合并单元格
    【PHP】PHPStorm中文乱码解决方式
    【DataBase】mysql连接错误:Cannot get hostname for your address
    【.NET】Browser Link: Failed to deserialize JSON in Browser Link call
  • 原文地址:https://www.cnblogs.com/TNSSTAR/p/2932814.html
Copyright © 2011-2022 走看看