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.

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