How do you use GetUserProfileSchema

Apr 13, 2015 at 5:17 PM
Hello all,

I'm thinking that GetUserProfileSchema will do what I want, but I could be wrong, like some other items I have attempted. I'm thinking it will give me back the fields that are available from the SharePoint Server, but I want to get the fields available for User IDs, i.e. similar to the SPGetCurrentUser information. I'm just wanting to see what fields are provided by my SharePoint server. Do they have any extra that aren't the standards? Perhaps I could just ask the admin, and I have, but I haven't heard back from them, yet. I just thought this might be an easier way of doing it.

I suppose more importantly, I want to be able to get information about users other than the one who is currently logged in. Oh, note, I am currently working with a SharePoint 2007 server.

Any thoughts?

Thank You.
Coordinator
Apr 13, 2015 at 5:38 PM
Edited Apr 13, 2015 at 5:55 PM
It depends. (Doesn't it always?)

SPGetCurrentUser pulls information from the Site Collection's User Information List. GetUserProfileSchema will pull the properties available in the User Profile Store. These are two different storage locations and serve different purposes. Below is an example of a call to the latter...

M.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetUserProfileSchemaResponse xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService">
<GetUserProfileSchemaResult>
<PropertyInfo>
<Name>UserProfile_GUID</Name>
<DisplayOrder>1</DisplayOrder>
<MaximumShown>10</MaximumShown>
<IsAdminEditable>false</IsAdminEditable>
<IsSearchable>true</IsSearchable>
<IsSystem>true</IsSystem>
<DisplayName>Id</DisplayName>
<Type>unique identifier</Type>
<AllowPolicyOverride>false</AllowPolicyOverride>
<DefaultPrivacy>Public</DefaultPrivacy>
<IsAlias>false</IsAlias>
<IsColleagueEventLog>false</IsColleagueEventLog>
<IsRequired>true</IsRequired>
<IsUserEditable>false</IsUserEditable>
<IsVisibleOnEditor>false</IsVisibleOnEditor>
<IsVisibleOnViewer>false</IsVisibleOnViewer>
<IsReplicable>false</IsReplicable>
<UserOverridePrivacy>false</UserOverridePrivacy>
<Length>0</Length>
<IsImported>false</IsImported>
<IsMultiValue>false</IsMultiValue>
<ChoiceType>Off</ChoiceType>
<TermSetId xsi:nil="true"></TermSetId>
</PropertyInfo>
<PropertyInfo>
<Name>AccountName</Name>
<DisplayOrder>4</DisplayOrder>
<MaximumShown>10</MaximumShown>
<IsAdminEditable>false</IsAdminEditable>
<IsSearchable>true</IsSearchable>
<IsSystem>true</IsSystem>
<DisplayName>Account name</DisplayName>
<Type>Person</Type>
<AllowPolicyOverride>false</AllowPolicyOverride>
<DefaultPrivacy>Public</DefaultPrivacy>
<IsAlias>true</IsAlias>
<IsColleagueEventLog>false</IsColleagueEventLog>
<IsRequired>true</IsRequired>
<IsUserEditable>false</IsUserEditable>
<IsVisibleOnEditor>true</IsVisibleOnEditor>
<IsVisibleOnViewer>false</IsVisibleOnViewer>
<IsReplicable>false</IsReplicable>
<UserOverridePrivacy>false</UserOverridePrivacy>
<Length>250</Length>
<IsImported>true</IsImported>
<IsMultiValue>false</IsMultiValue>
<ChoiceType>Off</ChoiceType>
<TermSetId xsi:nil="true"></TermSetId>
</PropertyInfo>
<PropertyInfo>
<Name>FirstName</Name>
<DisplayOrder>5</DisplayOrder>
<MaximumShown>10</MaximumShown>
<IsAdminEditable>true</IsAdminEditable>
<IsSearchable>true</IsSearchable>
<IsSystem>true</IsSystem>
<DisplayName>First name</DisplayName>
<Type>string (Single Value)</Type>
<AllowPolicyOverride>false</AllowPolicyOverride>
<DefaultPrivacy>Public</DefaultPrivacy>
<IsAlias>false</IsAlias>
<IsColleagueEventLog>false</IsColleagueEventLog>
<IsRequired>false</IsRequired>
<IsUserEditable>false</IsUserEditable>
<IsVisibleOnEditor>false</IsVisibleOnEditor>
<IsVisibleOnViewer>false</IsVisibleOnViewer>
<IsReplicable>true</IsReplicable>
<UserOverridePrivacy>false</UserOverridePrivacy>
<Length>250</Length>
<IsImported>true</IsImported>
<IsMultiValue>false</IsMultiValue>
<ChoiceType>Off</ChoiceType>
<TermSetId xsi:nil="true"></TermSetId>
</PropertyInfo>
...
Apr 13, 2015 at 5:51 PM
Thank you for the response Marc,

I see that the field name seems to be the XML '<Name>' entry after the '<PropertyInfo>' in the post you have. Was that a full listing? I'm hoping not. But if I parsed the returned value out and pulled all the '<Name>' entries out, I might be able to get the information I'm wanting. I am curious though, as it appears there is a 'GetUserProfileSchema' in the current SPServices, how do you use it? Again, I'm stuck with a SharePoint 2007 server right now.

Thank You.
Coordinator
Apr 13, 2015 at 5:54 PM
Sorry; I meant to add a ... above. Amended.

I just made this call to get the data above:
$().SPServices({
  operation: "GetUserProfileSchema"
});

M.
Apr 13, 2015 at 6:10 PM
Hello Marc,

Where did that output come out? I'm not as smart as I might look (sound) ;o) But, did you have a variable to assign that to? I tried just the
var returnedData = $().SPServices({
    operation: "GetUserProfileSchema"
});

console.log(returnedData);
and didn't seem to get anything coming back from the server, except [object Object]. I'm sure I could somehow get the data from that object, but, as I said, I'm a little slow.

Thank You.
Coordinator
Apr 13, 2015 at 6:29 PM
I just ran the code in the console and looked at the traffic in the developer tools.

The way you are doing it above, returnedData will be a promise, not the data.

Try this:
var p = $().SPServices({
    operation: "GetUserProfileSchema"
});
p.done(function() {
  $(p.responseXML).find("PropertyInfo > Name").each(function() {
    console.log($(this).text());
  });
});
M.
Marked as answer by trout0525 on 4/13/2015 at 11:39 AM
Apr 13, 2015 at 6:43 PM
Thanks a lot Marc. That did it. It gave me all the fields I was looking for and more. :o) You wrote more code than you needed to. Sorry I'm too slow to figure out how to use the IE developer tools. I probably should. Thanks again.