• 在MOSS的WebPart中使用UserProfile注意事项


    • 修改Web.config文件,原文初始情况如下:

    <compilation batch="false" debug="false">

          <assemblies>

             <add assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />

         </assemblies>

    增加2项:

      <add assembly="Microsoft.Office.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C" />

      <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

    如果启用了AD对象再增加:

       <add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

    如果启用的AJAX功能:

      <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    • 给出个例子,如下在MOSS中的WebPart中集成UserProfile
      l 如下在MOSS中的WebPart中集成UserProfile
                   
      using (SPSite site = new SPSite("http://" + Environment.MachineName ))
                      
      {
                          ServerContext context 
      = ServerContext.GetContext(site);
                          UserProfileManager profileManager 
      = new UserProfileManager(context);
                          
      string sAccount =  site.OpenWeb().CurrentUser.LoginName;
                          
      string tmpAboutMe = "";
                          
      if (profileManager.UserExists(sAccount))
                          
      {
                              UserProfile profile 
      = profileManager.GetUserProfile(sAccount);//读取用户配置文件 
                              PUsers pu = new PUsers();
                              pu.AboutMe 
      = profile[PropertyConstants.AboutMe].Value == null ? "" : profile[PropertyConstants.AboutMe].Value.ToString();
                              tmpAboutMe 
      = pu.AboutMe;
                              
      if(pu.AboutMe.Length > 100)
                                  pu.AboutMe 
      = pu.AboutMe.Substring(0,100);
                              pu.PictureUrl 
      = profile[PropertyConstants.PictureUrl].Value == null ?  "/_layouts/images/no_pic.gif" : profile[PropertyConstants.PictureUrl].Value.ToString();
                              pu.MyName 
      = profile[PropertyConstants.PreferredName].Value == null ? "" : profile[PropertyConstants.PreferredName].Value.ToString();
                              pu.MyDept 
      = profile[PropertyConstants.Department].Value == null ? "" : profile[PropertyConstants.Department].Value.ToString();
                              pu.Subphone 
      = profile[PropertyConstants.Office].Value == null ? "" : profile[PropertyConstants.Office].Value.ToString();

                              
      this.Image1.ImageUrl = pu.PictureUrl;
                              
      this.Image1.ToolTip = "用户显示图片";
                              
      this.lbName.Text = pu.MyName;
                              
      this.lbDept.Text = pu.MyDept;
                              
      this.lbSubPhone.Text = pu.Subphone;
                              
      this.lbAboutMe.Text = pu.AboutMe;
                              
      this.lbAboutMe.ToolTip = tmpAboutMe;
      …………………..
      }

  • 相关阅读:
    ElasticSearch 基础<转载>
    计算文本相似度方法总结(一)
    Java入门1---关键字、标识符、变量、运算符、流程控制、数组
    IntelliJ IDEA安装
    java代码转python代码
    python2和python3切换
    在markdown中插入github仓库中的图片
    MySQL:管理MySQL、事务(三)
    MySQL:查询、修改(二)
    MySQL:主键、外键、索引(一)
  • 原文地址:https://www.cnblogs.com/pccai/p/944677.html
Copyright © 2020-2023  润新知