1
我可以在sharepoint用户配置文件中添加和编辑值。但我无法删除UP的值。例如,我已将用户配置文件属性添加为“认证”,我可以使用C#代码将值添加到UP中。我想使用C#代码从userprofile中删除值。使用c#删除Sharepoint 2010用户配置文件中的值
我可以在sharepoint用户配置文件中添加和编辑值。但我无法删除UP的值。例如,我已将用户配置文件属性添加为“认证”,我可以使用C#代码将值添加到UP中。我想使用C#代码从userprofile中删除值。使用c#删除Sharepoint 2010用户配置文件中的值
我做了一些测试,在我的environement,这个工程:
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
}
}
}
如果您向我们提供更多信息,我可以编辑我的代码更详尽的样本。
你可以请你发布你的代码。 – STORM