【问题标题】:How to check if a another user is on the same or lower level in the company hierarchy?如何检查另一个用户是否在公司层次结构中的同一级别或较低级别?
【发布时间】:2009-10-08 08:33:52
【问题描述】:

我有这个:

UserProfile prof = getUserProfile(properties.CurrentUserId);
UserProfile toCheck = getUserProfile(anotherUsersId);

“prof”用户必须与“toCheck”用户处于更高或相同级别。如果“toCheck”位于较低级别,则他/她必须位于层次结构树的同一分支上。如果他们处于同一级别,则他们的经理必须相同。

有没有简单的方法来检查这个?

【问题讨论】:

  • 在你的情况下,什么定义了“级别”?
  • 某用户的经理高一级。公司里只有一名超级经理。所以层次树就像一棵真正的树,上下颠倒。
  • 我认为这是使用 Sharepoint UserProfile 类(命名空间 Microsoft.Office.Server.UserProfiles),我自己没有经验。如果不是这种情况,那么 Vili 需要发布他们的 UserProfile 类的代码。
  • 是的,这是一个 SharePoint 类。
  • 您使用的是 Microsoft.Office.Server.UserProfiles 命名空间还是旧版 Microsoft.Sharepoint.Portal 命名空间?

标签: c# sharepoint active-directory user-profile


【解决方案1】:

这里有一些方法可以帮助你:

我没有找到“简单的方法”,但您可以编写自己的帮助类来使用这些方法、遍历用户配置文件并找到您需要的信息。

顺便说一句:“同事”与此无关。它们是一组人员,通过完整的“我的网站”实施,用户可以管理自己。

【讨论】:

  • GetManager 是解决方案。但这不是一个简单的方法。 :)(非平凡(对我来说))递归是需要的。
【解决方案2】:

一些伪代码:

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;
}

【讨论】:

    猜你喜欢
    • 2013-10-28
    • 1970-01-01
    • 1970-01-01
    • 2022-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-01
    • 2021-04-22
    相关资源
    最近更新 更多