• 在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;
      …………………..
      }

  • 相关阅读:
    【BZOJ4568】幸运数字(SCOI2016)-树上倍增+异或线性基合并
    【BZOJ2115】XOR(WC2011)-异或线性基+DFS树+贪心
    【HDU3949】XOR-异或线性基
    【BZOJ3105】新Nim游戏(CQOI2013)-博弈论+异或线性基+贪心
    购物单 && 动态规划 && 背包问题
    求int型正整数在内存中存储时1的个数 && int型的数到底最大是多少?
    Eqaulize Prices
    Nearest Interesting Number
    英文句子的逆序
    字符串反转
  • 原文地址:https://www.cnblogs.com/pccai/p/944677.html
Copyright © 2020-2023  润新知