2016-01-14 80 views

回答

0

我做了一些测试,在我的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 
     } 
    } 
} 

如果您向我们提供更多信息,我可以编辑我的代码更详尽的样本。

相关问题