Getting additional profile fields that are synced with AD

Aug 14, 2013 at 3:18 PM
Edited Aug 14, 2013 at 3:18 PM
Hi

Will the next version of .SPGetCurrentUser be able to return custom properties held in a user's profile that are synced with AD ( through the usual UPS)?

For example:
var company = $().SPServices.SPGetCurrentUser({
fieldName: "Company",
debug: true
});
I guess my interest is both in SharePoint 2010 and 2013
Aug 14, 2013 at 7:09 PM
If the values are you are looking for are fields on the user profile page, then they should be accessible now... As the documentation states, this utility:
"...does an AJAX call to grab /_layouts/userdisp.aspx?Force=True and "scrapes" the values from the page based on the internal field name (aka StaticName)."
So take a look at the /_layouts/userdisp.aspx?Force=True and if the values you are looking for are displayed there, you can use the Internal field name to retrieve it.
Aug 16, 2013 at 10:20 AM
Edited Aug 16, 2013 at 10:28 AM
Hi

Thanks for the reply. Now, in my case I updated the company property in AD via PS script then did a sync with a custom property in Sp2010 though UPS

When I go to Edit User Profile property for the custom property: Company I have the following settings
  • Do not allow users to edit values for this property
  • Checked Show in the profile properties section of the user's profile page
  • Checked Show on the Edit Details page
  • Checked Show updates to the property in newsfeed
Source Attribute Direction
MyAD Company Import


However, /_layouts/userdisp.aspx does not have the company property which is why the SPGetCurrentUser does not return anything

However it is displayed both in

http://mysite.mydomain.com/_layouts/EditProfile.aspx? and layouts/ProfAdminEdit.aspx ( Edit user property in CA)

I guess the question is how can I get my custom property to appear in the user settings
Aug 17, 2013 at 6:02 PM
Not sure how you can do that (adding additional data to userdisp.aspx). Since that's no longer a SPServices question, if no one else has any feedback, I would suggest posting your question to StackExchange.

_____
Paul

Sent from mobile device.
Aug 17, 2013 at 9:54 PM
Paul

Thanks for your reply. I think that is a good suggestion. I will follow up and let you know.


Daniel
Coordinator
Aug 29, 2013 at 10:03 PM
Daniel:

There's a difference between the User Profile and the userdisp.aspx info. The latter is present for all users who have "touched" the Site Collection, regardless the license level. i.e., even for Foundation.

If you want to access the User Profile properties, you should use the User Profile Service instead.
https://spservices.codeplex.com/wikipage?title=UserProfileService&referringTitle=%24%28%29.SPServices

M.
Sep 2, 2013 at 1:50 PM
Edited Sep 2, 2013 at 1:56 PM
Marc


Thanks for your explanation. The userdisp.aspx seem to be a fixed set of properties for those users who as you say have "touched" the site collection. Assuming, I can't add my custom AD property "Company" to this page then I am left with some options I need to explore on my test SP2010 server in order to extract the company name stored as custom user profile property and synced with AD.
$().SPServices({
  operation: "GetUserProfileByName",
  async: false,
  AccountName: "Mydomain\\Dantheman",
  completefunc: function (xData, Status) {
    company = getUPValue(xData.responseXML, "Company");
    
   }
});
or maybe this


[http://aymkdn.github.io/SharepointPlus/symbols/%24SP%28%29.html#.people](SP.People function)

Any thoughts before I try both out.
Coordinator
Sep 2, 2013 at 4:00 PM
Assuming your getUPValue function works, that's the way to go.

M.
Sep 2, 2013 at 9:21 PM
Mark

Spot on, with GetUserProfleByName() I was able to locate the Company custom AD attribute . I didn't bother with the AcountName parameter which defaulted to my current user. I then copied the "Company" name string to a variable and displayed it on my sample home page I have used in my latest blog post which I will update with this tomorrow. Thanks once again for getting me on track.