【发布时间】:2016-01-14 07:32:35
【问题描述】:
我可以在 sharepoint 用户配置文件中添加和编辑值。但我无法从 UP 中删除值。例如,我已将用户配置文件属性添加为“Certifications”,我可以使用 C# 代码将值添加到 UP 中。我想使用 C# 代码从用户配置文件中删除值。
【问题讨论】:
-
能否请您发布您的代码。
标签: sharepoint sharepoint-2010
我可以在 sharepoint 用户配置文件中添加和编辑值。但我无法从 UP 中删除值。例如,我已将用户配置文件属性添加为“Certifications”,我可以使用 C# 代码将值添加到 UP 中。我想使用 C# 代码从用户配置文件中删除值。
【问题讨论】:
标签: sharepoint sharepoint-2010
我在我的环境中做了一些测试,这很有效:
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
}
}
}
如果您向我们提供更多信息,我可以编辑我的代码以获得更详细的示例。
【讨论】: