다음을 통해 공유


UserProfileService Class

Provides a Web service to manage user profiles.

Inheritance Hierarchy

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Web.Services.Protocols.WebClientProtocol
        System.Web.Services.Protocols.HttpWebClientProtocol
          System.Web.Services.Protocols.SoapHttpClientProtocol
            [UserProfileService Web service].UserProfileService

Namespace:  [UserProfileService Web service]
Web service reference: http://Site/_vti_bin/UserProfileService.asmx

Syntax

'Declaration
<WebServiceBindingAttribute(Name := "UserProfileServiceSoap", Namespace := "https://microsoft.com/webservices/SharePointPortalServer/UserProfileService")> _
Public Class UserProfileService _
    Inherits SoapHttpClientProtocol
'Usage
Dim instance As UserProfileService
[WebServiceBindingAttribute(Name = "UserProfileServiceSoap", Namespace = "https://microsoft.com/webservices/SharePointPortalServer/UserProfileService")]
public class UserProfileService : SoapHttpClientProtocol

Examples

The following example shows how to get information about the membership of a user, colleagues of a user, links, and user profile property data. Make sure you add a Web reference to a UserProfileService Web service site to which you have access. Change the using GetProfileDataSample.MyServer002; directive to point to the Web service site you are referencing. In addition, replace "domain\\username" with valid values.

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

// TODO 
// Change the using GetProfileDataSample.MyServer002 directive
// to point to the Web service you are referencing.
using GetProfileDataSample.MyServer002;

namespace GetProfileDataSample
{
    class Program
    { 
        //Instantiate the Web service. 
        public static UserProfileService userProfileService = new UserProfileService();

        static void Main(string[] args)
        {
            //Set credentials for requests.
            //Use the current user log-on credentials.
            userProfileService.Credentials =
                System.Net.CredentialCache.DefaultCredentials;

            GetUserProfilePropertyData();
            GetUserMemberships();
            GetUserColleagues();
            GetUserLinks();
        }

            static void GetUserProfilePropertyData()
        {
            // TODO 
            // Replace "domain\\username" with valid values.
            PropertyData[] properties = 
                userProfileService.GetUserProfileByName("domain\\username");
            for (int i = 0; i < properties.Length; i++)
            {
                Console.WriteLine(properties[i].Name);
                Console.WriteLine(properties[i].Values);
            }

            Console.Read();
        }
         static void GetUserMemberships()

        {
            // TODO 
            // Replace "domain\\username" with valid values.
            MembershipData[] memberships = 
                userProfileService.GetUserMemberships("domain\\username");
            for (int i = 0; i < memberships.Length; i++)
            {
                Console.WriteLine(memberships[i].DisplayName);
            }

            Console.Read();
        }

        static void GetUserColleagues()
        {
            // TODO 
            // Replace "domain\\username" with valid values.
            ContactData[] contacts = 
                userProfileService.GetUserColleagues("domain\\username");
            for (int i = 0; i < contacts.Length; i++)
            {
                Console.WriteLine(contacts[i].Name);
            }
            Console.Read();
        }

        static void GetUserLinks()
        {
            // TODO 
            // Replace "domain\\username" with valid values.
            QuickLinkData[] links = 
                userProfileService.GetUserLinks("domain\\username ");
            for (int i = 0; i < links.Length; i++)
            {
                Console.WriteLine(links[i].Url);
            }

            Console.Read();
        }
        }
    }

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

UserProfileService Members

UserProfileService Web Service