This project has moved and is read-only. For the latest updates, please go here.

Get user profile by ID

Jun 21, 2011 at 4:49 PM


Can I access the user profile using the info in a people field (by the form 5;#LastName, FirstName? I've tried to use the GetUserProfileByIndex with no luck and can't find any better...


Jun 25, 2011 at 4:36 PM


I just did a quick test and was able to retrieve a user profile with GetUserProfileByIndex just by supplying the index number, as shown in the SDK:

index: 5,

Give that a try.


Jun 26, 2011 at 3:19 AM


I take this back. It was bugging me in the back of my mind a bit and I just looked at the implementation in SPServices for GetUserProfileByIndex. It turns out that I'm not actually passing any parameters to the operation, which is basically a bug.

If you add the following code at line 855 in v0.6.2, then you'll have the proper implementation:

   case "GetUserProfileByIndex":
    addToPayload(opt, ["index"]);

I'll get this fix into the first alpha for v0.6.3, but there it is if you want to use it. I'm not certain what value index should hold. When I pass the ID for the user with this fix, I do not get the results I'd pexpect.


Jun 26, 2011 at 3:34 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jun 26, 2011 at 3:36 AM

A little more research...

You should use GetUserProfileByName, if possible. It seems that GetUserProfileByIndex hardly does what one would expect, vis


Jun 26, 2011 at 4:14 AM

New post on my blog about this:


Jun 27, 2011 at 10:15 AM

The update in the alpha works, and when I think about it probably as expected. The UserProfileService queries the user profiles and that's not site collection specific so the user index id is the one there, not in the current site.

So the only way to get the user profile from the id provided in a people field is to first query the User Information List? Don't you need full permission to query that list?


Jun 27, 2011 at 1:27 PM

I haven't had any luck with querying that list *without* elevated privileges.  I'm interested in your results.  Let us know what you find.



Jun 27, 2011 at 1:33 PM

The User Information List is specific per Site Collection. That's why I suggest using GetUserProfileByName instead of GetUserProfileByIndex. It seems that in order to identify the right user profile using GetUserProfileByIndex, you'd need to loop through them all until you found the right name, anyway. At least that's how I read those blog posts.

I've read the UIL successfully in the past, but the user doing so needs to have permissions to see it. The easiest proxy for that is whether they can see People and Groups in the Quick Launch.


Jun 28, 2011 at 10:59 AM

I think I tried all pretty ways to solve this now, but still haven't found any working. Solved it in a not so pretty way instead.

I created an empty aspx page (peoplefunc.aspx), everything stripped out, with a DVWP on showing only the peoplefield. The people field in a DVWP shows the SIP-address that can be used in GetUserProfileByName.

<xsl:value-of select="substring-before(substring-after(@Responsible, 'sip:'), '@')" />

I then get the value with ajax to call the web service.

		url: ''+itemId,
		success: function(data) {
			operation: "GetUserProfileByName",
			AccountName: $(data).find('div').text()+'',
			completefunc: function (xData, Status) {				

Far from a pretty solution, but ended up to be quite quick


Jun 28, 2011 at 1:10 PM

Well, it seems as though that would work. I would think that you'd also be able to look up the SIP-address from the User Information List using GetListItems, assuming the user running the page had permissions.

If it were the current user, you could use $().SPServices.SPGetCurrentUser, but it doesn't look like that is the case.


Jun 28, 2011 at 3:12 PM

Thousands of users, so don’t think UIL will work this time, even though that might be smother.


Jun 28, 2011 at 3:21 PM

Looking up in the UIL ought to be no less efficient than your peoplefunc.aspx page, but it seems like you have a solution that works for you.


Jun 28, 2011 at 4:13 PM

I actually think the UIL is more efficient, but then I had to change the permission for all "reader" users...

Jun 29, 2011 at 11:12 AM

Just my little FYI as I am currently on WSS only. We use the UIL and basically going to this list and going to its permissions give "Authenticated Users" read access to the list. This has worked every time but as I said, we only have WSS so it is what works.

Mar 7, 2012 at 5:59 PM

Note to self and other intersted....

CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",
returns account name, email, and name instead of just the name

Mar 7, 2012 at 8:17 PM

Cool fereko... I'll be adding that to roboCAML in an upcoming version after some testing.  Thanks for the tidbit!