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

Using UserProfileService to get all employees who report to a manager

Nov 3, 2011 at 4:02 PM


I have the AccountName of a manager that I want to pass to a service to bring back all their employees (i.e. any person whose user profile has Manager=AccountName).

Mentally it would be like if I could pass a caml query with the manager's name to GetUserProfileByName, and return all the PreferredNames of the folks reporting to the Manager.

Is there any UserProfileService that does that?


Nov 6, 2011 at 3:40 AM

Alas, I don't think there is an operation like what you describe. I just took a quick look through the available Users and Groups operations, and I don't see anything analogous.


Nov 7, 2011 at 3:51 PM

I found this page - and being a newbie am not sure if I can use SPServices to do something similiar...

It speaks of doing a Search webservice to gather people info.....anythoughts?

Nov 8, 2011 at 1:37 AM
The Search Web Services is wrapped in SPServices, so you can certainly call it. Check the docs for the syntax (with links to the SDK).

Nov 8, 2011 at 1:08 PM

I am 99% there - I just need my corp SP team to include Manager in the People search scope as an indexed field - I have used other existing indexed fields and this works:

I have already found the manager AccountName, and have it as variable mName:


var queryText = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'><Query><Context><QueryText language='en-US' type='MSSQLFT'>SELECT  PreferredName, Title, Path, Description, Write, Rank, Size  FROM SCOPE() WHERE \"scope\" = 'People' AND Manager LIKE '" + mName + "'</QueryText></Context><Range><StartAt>1</StartAt><Count>100</Count></Range></Query></QueryPacket>";

            operation: "Query",
            queryXml: queryText,
            completefunc: function(xData, Status) {
                $(xData.responseXML).find("QueryResult").each(function() {


It dumps the XML in the CEWP div id=results and looks great!  Then all that is left is to parse through the returned xml!!