sharepoint 2010 获取用户信息UserProfile方法 1.引用dll文件.在vs2010项目中,添加Microsoft.Office.Server.dll,Microsoft.Office.Server.UserProfiles
2.获取用户登录名,例如cxx\mossadmin毕业论文
string LoginName=System.Web.HttpContext.Current.User.Identity.Name.ToString();
3.根据用户名获取UserPorfile
/// <summary> /// 根据用户名获取UserProfile /// </summary> /// <param name="loginName"></param> /// <returns></returns> public static UserProfile GetUserProfileByLoginName(string loginName) { UserProfile userProfile = null; SPSecurity.RunWithElevatedPrivileges(delegate() { SPSite site = new SPSite(SPContext.Current.Site.Url); SPWeb web = site.RootWeb; SPUser user = web.EnsureUser(loginName); //当用户不存在时,自动将改用户添加到sharepoint中 ServerContext sc = ServerContext.GetContext(site); UserProfileManager profileManager = new UserProfileManager(sc); if (profileManager.UserExists(loginName)) { userProfile = profileManager.GetUserProfile(loginName); //读取用户配置文件
[1] [2] 下一页
|