const string siteUrl = "http://server/sites/sitename"; const string user = "domain\\username"; using (SPSite site = new SPSite(siteUrl)) { SPUser userContext = site.RootWeb.SiteUsers[user]; SPUserToken userToken = userContext.UserToken; SPServiceContext serviceContext = SPServiceContext.GetContext(site); using (new SPServiceContextScope(serviceContext)) { UserProfileManager profileManager = new UserProfileManager(serviceContext); UserProfile userProfile = profileManager.GetUserProfile(userContext.LoginName); SPSocialFeedManager feedManager = new SPSocialFeedManager(userProfile, serviceContext, userToken); SPSocialPostCreationData post = new SPSocialPostCreationData(); post.ContentText = "Hi from server object model"; feedManager.CreatePost(site.Url+"/newsfeed.aspx", post); } }
Quote:FYI: Today we installed the SharePoint February 2016 CU in our farm. (Build: 15.0.4797.1000) And we can confirm that this is finally working again.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)