Export (0) Print
Expand All

How to: Use the Web Service to Modify User Profile Data

Last modified: October 01, 2009

Applies to: SharePoint Server 2010

Microsoft SharePoint Server 2010 enables you to update user profile data remotely by using the User Profile Service Web service.

The following example shows you how to update the home phone number of a user. You must add a Web reference to the User Profile Service Web service before you execute this code.

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

Before you use this code, replace domainname, username, and telephone numbers (nnnnnnnnnn) with actual values. Also add a Web reference to the following in your Microsoft Visual Studio project:

  • userprofileservice

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

namespace UserProfileWebServiceApp
{
    class Program
    {
        public static localhost.UserProfileService myService =
            new localhost.UserProfileService();
        UserProfileWebService.localhost.PropertyData[] newdata = 
    new UserProfileWebService.localhost.PropertyData[1];
            newdata[0] = 
                new UserProfileWebService.localhost.PropertyData();
            newdata[0].Name = "HomePhone";
            newdata[0].Values = new ValueData[1];
            newdata[0].Values[0] = new ValueData();
            newdata[0].Values[0].Value = "nnnnnnnnnnn";
            newdata[0].IsValueChanged = true;
            myService.ModifyUserPropertyByAccountName("domainname\\username", 
                newdata);

    }
}

Show:
© 2015 Microsoft