How to: Use the Web Service to Add Links and Colleagues

Last modified: May 30, 2008

Applies to: SharePoint Server 2010

The User Profile Service Web service provides methods that allow you to add links and colleagues. The following code example shows you how to use the Web service to add links and colleagues remotely.

Before running this code, replace domainname, username, and other placeholders with actual values. Also add a Web reference to the following in your Microsoft Visual Studio project:

  • Userprofileservice - The Web service is located at http://<site URL>/_vti_bin/userprofileservice.asmx.

using System;
using System.Collections.Generic;
using System.Text;

namespace UserProfileWebServiceApp
{
    class Program
    {
        public static localhost.UserProfileService myService =
            new localhost.UserProfileService();
        
        myService.AddLink("Training Resources","http://newhiretraining","Training",UserProfileWebService.
    localhost.Privacy.Organization);

        myService.AddColleague("domainname\username", "Personal", UserProfileWebService.localhost.Privacy.Private);

    }
}
Show: