I've got this:
UserProfile prof = getUserProfile(properties.CurrentUserId);
UserProfile toCheck = getUserProfile(anotherUsersId);
"prof" user must be on a higher or on the same level as "toCheck" user. If "toChe开发者_运维问答ck" is on a lower level he/she must be on the same branch of the hierarchy tree. If they are on the same level, their manager must be the same.
Is there an easy way to check this?
There are a few methods that should help you here:
- GetPeers
- GetManagers
- GetDirectReports
There is no "easy way" that I've found but you can write your own helper classes that use these methods, traverse the user profiles, and find the information you need.
As an aside: "Colleagues" is not related to this. They are a list of people that, with a complete My Site implementation, users can manage themselves.
Some pseudo code:
function compare(manager, toCheck, prof)
{
toManager=toCheck.manager;
if (toManager!=null)
{
if (manager==tomanager || prof==tomanager)
{
return true;
}
else
{
return compare("", tomanager, prof);
}
}
else // he/she is the boss
{
return false;
}
}
...
if (prof.manager!=null)
{
compare(prof.manager, toCheck, prof);
}
else // he/she is the boss
{
return true;
}
精彩评论