MOSS 2007 MySite Organization Hierarchy

Page Title:

If you've used MOSS 2007 MySite's, then you're likely familiar with the Organization Hierarchy web part on the main profile page that displays your peers and manager.  Don't know if anyone else would ever need/want to do this, but in our organization we were in need of not displaying the organization hierarchy of a particular department.

I've been unable to find any documentation on this feature, asside from it being powered by the manager listed for each employee in active directory.  When our need to exclude this department first came up, I just stopped importing Manager from AD so this would not be populated.  If you want to completely remove this web part's information, then read no further as un-mapping manager from AD to the Manager profile property will do the trick for you.   In our case, there's since been movement to start using MySites more and so we wanted to be able to display this information, but again, exclude this one department.  

I was finally able to track down the key, the stored procedure in your Shared Services database for the site called profile_GetUserReportToData.   This is where the hierarchy information comes from.   So now all I had to do was modify the queries in this stored procedure to exclude anyone from the department in question.   Just add to the end of the WHERE clauses:

AND NOT V.RecordID IN (SELECT V2.RecordID FROM UserProfileValue V2
WHERE V2.RecordID = V.RecordID AND V2.PropertyID = 14
AND CAST(V2.PropertyVal as nvarchar(150)) LIKE 'DeptName%')

Your PropertyID may be something other than 14, so just check the UserProfileValue table first to see which one has the department information in it.  And DeptName would be the name of the department you're excluding. 

Disclaimer: Making changes to your SharePoint database directly could be dangerous to the stability of your install and be undone by future upgrades. Do this at your own risk.

Relevant Tags: SharePoint