Click here to Skip to main content
13,090,299 members (90,580 online)
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 26 Apr 2007

Accessing SharePoint UserProfile Services in Infopath 2007

, 26 Apr 2007
Rate this:
Please Sign up or sign in to vote.
Access UserProfile Services in Infopath 2007.

Screenshot - Infopath_Security_Trust.jpg


This article explains how to access SharePoint Userprofile Services in Infopath Form. It also explains about the configuration settings.

Using the code

This code assumes that the SharePoint(MOSS) server contains EmployeeId and Preferred Name properties.

First add a web reference (http://MOSSSERVERNAME/_vti_bin/userprofileservice.asmx). I gave the web reference name as localhost. If you like, you can have a different name. Then you have to change the code.

private string GetUserProfileByEmployeeId(string EmpId)
    string displayName = string.Empty;
    localhost.UserProfileService myUPWS = new localhost.UserProfileService();
    myUPWS.Credentials = System.Net.CredentialCache.DefaultCredentials;
    long profileCount = myUPWS.GetUserProfileCount();
    localhost.GetUserProfileByIndexResult up;
    localhost.PropertyData[] propdata;
    for (int j = 0; j < profileCount; j++)
        up = myUPWS.GetUserProfileByIndex(j);
        propdata = up.UserProfile;
        if (propdata[propdata.Length - 1].Values.Length > 0)
            if (propdata[propdata.Length - 1].Values[0].Value.ToString() 
                                == EmpId)
                displayName = propdata[4].Values[0].Value.ToString();
    return displayName;

So, the above code returns the Preferred Name when you pass EmployeeId to the UserProfile Services. Since we are using webservices in the Infopath form, we have to change the Security Level to "Full Trust". Also, if the form is to be accessed from a different machine other than the development machine or the MOSS server machine, we have to sign the form.

In addition, we have to configure the IIS of the MOSS server so that Infopath form can access UserProfile Services from a different machine.

  • Go to IIS and look for UserProfileServices.asmx file and click on Properties.
  • Click on 'Edit' on Secure Communications section.

    Screenshot - UserProfileService_Asmx.jpg

  • Now select 'Accept Client Certificate' and say OK.

    Screenshot - SecureCommunications.jpg

This will enable the Infopath form to access UserProfile service from a different machine.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 26 Apr 2007
Article Copyright 2007 by Saravanan20152
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid