locked
Sharepoint 2010 social network API Activity feeds RRS feed

  • Question

  • Q1) Do you know how to broadcast an activity feeds to other users to see without been added as colleague? Lets assume that we writing a SharePoint news application and we need to post every news we add to that application to the every users activity feeds in the organization. Here we don't have a colleague concept, only the news application we need to see. How do we archive this kind of requirement using SharePoint 2010 social network API.

    Q2) I want to see some particular person's activity feeds by logging as a profile administrator. Every time i tried to run the following code it gives the logged users activity feeds not the feeds for the perticuler user i want to see. It seems that ActivityManager taking the logged user to get the activity feeds from API. Is there any way we can archive this.

           public void LoadAll()

            {

                SPSecurity.RunWithElevatedPrivileges(delegate()

                {

                    SPSite osite = new SPSite("http://navintradev01:33059/");

                    SPServiceContext currentContext = SPServiceContext.GetContext(osite);

                    //Get the UserProfileManager from SPServiceContext.

                    UserProfileManager userProfMan = new UserProfileManager(currentContext);

                    //Get the current user.

                    UserProfile currentUser = userProfMan.GetUserProfile(@"domainx\sp2010installer");

                    //Get the ActivityManager from the user and context.

                    ActivityManager activityMan = new ActivityManager(currentUser,currentContext);

                    ActivityEventsCollection eventsCollection = activityMan.GetActivitiesForMe();

                    foreach (ActivityEvent activity in eventsCollection)

                    {

                        if (activity.LinksList != null)

                        {

                            string value = activity.Value;

                            ListBox1.Items.Add("publisher - "+activity.Publisher.Name);

                            ListBox1.Items.Add("owner     - "+activity.Owner.Name);

                            ListBox1.Items.Add("activity  - "+ activity.Name);

                            ListBox1.Items.Add("Value     - "+ activity.Value);

                            ListBox1.Items.Add("-----------------------");

                        }

                    }

                });

            }

    Regards,

    Chinthaka.

    Wednesday, February 2, 2011 2:21 PM

Answers

  • You are correct, Chinthaka. You cannot impersonate the activity manager... not with elevated priveledge or other means! In fact, no where in the Social APIs do they support impersonation.

    >> Do you know why ActivityManager needs user profile object to create a new object? 

    Just guessing, but when they wrote the code they probably thought they'd support impersonation, but then decided against it for security reasons.


    Daniel Larson SharePoint Architect at NewsGator Technologies, Author for Microsoft Press, Father of VI and Eli
    • Marked as answer by Wayne Fan Thursday, February 10, 2011 1:24 AM
    Thursday, February 3, 2011 7:36 PM

All replies

  • 1. You need to publish it to each recipient. This is known as "multicasting", but this is a pretty advanced topic. If you have code that publishes to colleagues, this would be similar, you'd just have to enumerate through EVERY user in the profile store that you want to publish to.

    2. There is no supported API for impersonating another user in the activity manager.


    Daniel Larson SharePoint Architect at NewsGator Technologies, Author for Microsoft Press, Father of VI and Eli
    • Proposed as answer by daniel.larson Wednesday, February 2, 2011 4:40 PM
    Wednesday, February 2, 2011 4:40 PM
  • Hi,

    I had also difficulties with impersonation when working with the social API. You can read more about that here:
    How we can’t set rating in the name of other users from code?
    http://pholpar.wordpress.com/2010/12/16/how-we-cant-set-rating-in-the-name-of-other-users-from-code/

    But I dont's see why should one impersonate another user when working with the ActivityManager. The documentation of its constructor (http://msdn.microsoft.com/en-us/library/ee586271.aspx) says about the userProfile parameter:
    "The UserProfile object representing the user who will be treated as the current user for this ActivityManager." (without impersonating that user)

    Do you mean that you cannot use this in an elevated privilages block, and if you do it, and the original caller has no permission to see the activity of other users, it will fall back to the original caller user?

    Peter

     

    Wednesday, February 2, 2011 5:09 PM
  • The answer to the question is yes. When I use activity manager and get the activity feeds it always return the current context users activity feeds not the feeds that I passed to create activity manager object.

    Do you know why ActivityManager needs user profile object to create a new object? 

     

     

    Thursday, February 3, 2011 6:49 AM
  • You are correct, Chinthaka. You cannot impersonate the activity manager... not with elevated priveledge or other means! In fact, no where in the Social APIs do they support impersonation.

    >> Do you know why ActivityManager needs user profile object to create a new object? 

    Just guessing, but when they wrote the code they probably thought they'd support impersonation, but then decided against it for security reasons.


    Daniel Larson SharePoint Architect at NewsGator Technologies, Author for Microsoft Press, Father of VI and Eli
    • Marked as answer by Wayne Fan Thursday, February 10, 2011 1:24 AM
    Thursday, February 3, 2011 7:36 PM
  • Hi Daniel,

    I am facing similar issue with social networking API, can you please help me with the post below.

    http://social.technet.microsoft.com/Forums/en-AU/sharepoint2010programming/thread/e9dba9d9-624d-46fe-8d6b-e86014b714ee

    Thanks in advance
    Ajay Sawant


    Friday, May 4, 2012 5:49 PM