zoukankan      html  css  js  c++  java
  • Elevate Permissions To Modify User Profile

    We can using the following code to elevate permissions to modify user profile:

     1 try
    2 {
    3 SPSecurity.RunWithElevatedPrivileges(delegate()
    4 {
    5 HttpContext curcon = HttpContext.Current;
    6 using (SPSite mySite = new SPSite("http://YourSiteURL"))
    7 {
    8 SPServiceContext context = SPServiceContext.GetContext(mySite);
    9 HttpContext.Current = null;
    10 UserProfileManager upm = new UserProfileManager(context, true);
    11 UserProfile userpro = upm.GetUserProfile(userLoginName);
    12
    13 //modify the value of some properties,change the old value to your value
    14 userpro["PropertyName"].Value = yourvalue;
    15
    16 userpro.Commit();
    17 }
    18 HttpContext.Current = curcon;
    19 });
    20 }
    21 catch (Exception ex)
    22 {
    23 //throw some exceptions
    24 }
  • 相关阅读:
    排序算法的稳定性
    字符串处理常用函数
    判断两棵二叉树是否相等
    约瑟夫环
    自加++
    Linux 安装配置 Tomcat
    在 eclipse 中将 web 项目部署到 tomcat 服务器上
    PHP连接MySQL数据库
    logback
    Log4J
  • 原文地址:https://www.cnblogs.com/leolis/p/2380607.html
Copyright © 2011-2022 走看看