【问题标题】:Delete values from Sharepoint 2010 user profile using c#使用 c# 从 Sharepoint 2010 用户配置文件中删除值
【发布时间】:2016-01-14 07:32:35
【问题描述】:

我可以在 sharepoint 用户配置文件中添加和编辑值。但我无法从 UP 中删除值。例如,我已将用户配置文件属性添加为“Certifications”,我可以使用 C# 代码将值添加到 UP 中。我想使用 C# 代码从用户配置文件中删除值。

【问题讨论】:

  • 能否请您发布您的代码。

标签: sharepoint sharepoint-2010


【解决方案1】:

我在我的环境中做了一些测试,这很有效:

using (SPSite site = new SPSite("http://xxx/"))
{
    using (SPWeb web = site.OpenWeb())
    {
       try
       {
           SPServiceContext serviceContext = SPServiceContext.GetContext(site);
           UserProfileManager userProfileManager = new UserProfileManager(serviceContext);
           UserProfile userprofile = userProfileManager.GetUserProfile("your login");
           //Set value
           userprofile["Department"].Value = "StackOverflow";
           userprofile.Commit();
           //Remove value
           userprofile["Department"].Value = "";
           userprofile.Commit();
      }
      catch (Exception ex)
      {
          //TO DO
      }
   }
}

如果您向我们提供更多信息,我可以编辑我的代码以获得更详细的示例。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-31
    相关资源
    最近更新 更多