0

I have a working app that uses's a client side people picker to find users...Once i have my user selected i then need to get the selected users Manager and department.

I don't think this is readily available from the user info, is there a way to query the AD via client side?

3
  • Is the Manager property set in User Profiles? If so, you can use REST: <site url>/_api/SP.UserProfiles.PeopleManager/getuserprofilepropertyfor(accountName=@v,propertyName='Manager')?@v='domain\\user' (might have to encode username)
    – wjervis
    Jun 23, 2014 at 15:11
  • Does this give you the manager name only? I will need the Manager ID also unless i will need to make another call to get the manager ID using the name...seem like a lot of hard work!
    – Stephen
    Jun 23, 2014 at 15:32
  • You can use getpropertiesfor instead of getuserprofilepropertyfor to list all properties. msdn.microsoft.com/en-us/library/office/…
    – wjervis
    Jun 23, 2014 at 15:50

1 Answer 1

2

You can use GetUserProfileByName operation of SPServices library to query user profile properties of user.Since manager property is "Person" field , you will be able to get ID and name of the manager. Below is a code sample for the same:

$().SPServices({
  operation: "GetUserProfileByName",
  async: false,
  AccountName: "domain\\loginname",
  completefunc: function (xData, Status) {
      office = getUPValue(xData.responseXML, "Manager");
   }
});

function getUPValue(x, p) {
  var thisValue = $(x).SPFilterNode("PropertyData").filter(function() {
    return $(this).find("Name").text() == p;
  }).find("Values").text();
  return thisValue;
}
1
  • thanks for that...I've had a look at SPServices before and whilst its excellent, i'm not using it in this project.
    – Stephen
    Jun 24, 2014 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.