javascript proxy for the SharePoint User Profile web service
I’ve updated the javascript API for the SharePoint web services to version 1.0.1. This now includes support for the User Profile web service (/_vti_bin/UserProfileService.asmx) allowing user profiles to be retrieved and updated.
The extra proxy is located in the SPAPI_UserProfile.js file. The following example demonstrates the usage of the proxy by getting the first name and preferred name of a user from their login name.
var profile = new SPAPI_UserProfile('')
var profileData = profile.getUserProfileByName('GLASGOW\\darrenj');
if (profileData.status == 200)
{
var properties = profileData.responseXML.getElementsByTagName('PropertyData');
var propertyValues = new Array();
for (var i=0; i<properties.length; i++)
{
var propName = properties[i].getElementsByTagName('Name')[0].childNodes[0].nodeValue;
propertyValues[propName] = properties[i].getElementsByTagName('Value');
}
alert('First name is: ' + propertyValues['FirstName'][0].childNodes[0].nodeValue);
alert('Preferred name is: ' + propertyValues['PreferredName'][0].childNodes[0].nodeValue);
}
else
{
alert('There was an error: ' + profileData.statusText);
}
The javascript above parses the response XML and creates a hash table of XML nodes keyed by the property name. Note that a property may have more than one value so the hash table stores arrays of these values.
So to get the user’s first name we use:
propertyValues['FirstName'][0].childNodes[0].nodeValue;
…and for the preferred name…
propertyValues['PreferredName'][0].childNodes[0].nodeValue;
I’ll post some more examples on the use of the profile service when I get a chance.
Popularity: 37% [?]

Comment by Preston on 22 January 2009:
Let me know if this is possible.
The scenario is using a CEWP to build out a list of links to all the site collections (and their subsites) on a single farm. The client wants a tree view of all the sites on a page at every site collection.
I’m getting an access denied error when polling a different site collection from the current site with the CEWP. I assume the javascript isn’t passing along the credentials of the currently logged on user. Is it possible to pass this information along to the 2nd site collection?
Comment by Bill Nash on 4 February 2009:
This is a great way to return a specific user, but is there a similar way to return a of all the users in the same “Department”?
Comment by darren on 15 February 2009:
Hi Bill, See the example here for a good starting point http://darrenjohnstone.net/2008/07/22/examples-for-the-sharepoint-and-office-live-javascript-api/#topic-13. Cheers
Comment by Bowencoke on 8 June 2009:
also budget casino royale .gallup nm casino poker online indy downs casino .about casino poker hawaiian gardens casino .hotel riviera and casino las vegas it contain .free online poker games may be casino beirut vacatures holland casino free casino online .
Comment by SeanW on 19 June 2009:
Darren, I may have gone about this the wrong way, but take a look and see what you think.
I had a need to get user group info for any user that was filling out a form. The code samples I’ve found here on your site required the user to be an admin in order to query that hidden user list. I found a web service on CodePlex that will query for the current user’s username and groups, and it’s been working great! I made a new function to consume this webservice (following your format), and used your core execute function to fire off the request.
Anyway, rather than paste a bunch of code here in your comments, I’ve posted it over at Pastey.net – take a look:
http://www.pastey.net/116299-5jqt
Do you have something in your code that I’ve missed that will do this, or is this a shortcoming of SharePoint that the custom web service has gotten around?
Thanks for the AWESOME library!!
-Sean
Comment by Steve on 15 September 2009:
Hello,
I am trying to get this to work. I get a 200 returned for a good connection but properties.length = 0. I have tried query by user ID and GUID. Not sure what is goign wrong. I have sucessfully used on of the other .js libraries so I don’t think I am totally off my rocker.
Can anyone see a problem with tihs?
BTW, I am really new to js so if the answer is obvious don’t beat me too hard…
Thanks,
Steve
var profile = new SPAPI_UserProfile(‘http://secpoint:8889′);
var profileData = profile.getUserProfileByGuid(‘A7ADDE20-3FE3-4AA5-AA33-777BF4BB6FC7′);
if (profileData.status == 200)
{
etc……
Comment by Polprav on 11 October 2009:
Hello from Russia