In my custom webpart, I want to show the number of comments. I try to get this throug SocialCommentManager.GetComments and then return comments.Count.
The problem is: I get only comments for the current user. Say, there are three comments on a page, one is mine. On startpage in a custom webpart I see that there is only one comment.
Even if I run with elevated, the users get only the number of their comments.
int number;
SocialComment[] comments = null;
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite esite = new SPSite(SPContext.Current.Site.ID))
{
var sc = SPServiceContext.GetContext(esite);
var soc = new SocialCommentManager(sc);
comments = soc.GetComments(uri, maxNumberOfComments);
number = comments.Count();
}
});
While logged in as System Account, I get all (System Account is set as the administrator on User Profile Service).
Any ideas?