【IT168技术文档】
修改Web.config文件,原文初始情况如下:
增加2项:<compilation batch="false" debug="false"> <assemblies> <add assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> </assemblies>
如果启用了AD对象再增加:<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" />
如果启用的AJAX功能:<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
给出个例子,如下在MOSS中的WebPart中集成UserProfile<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
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; ………………….. }