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

本文链接:https://www.cnblogs.com/pccai/archive/2007/10/31/944677.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现