Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何检查另一个用户是否在公司层次结构中处于同一级别或更低级别?_C#_Sharepoint_Active Directory_User Profile - Fatal编程技术网

C# 如何检查另一个用户是否在公司层次结构中处于同一级别或更低级别?

C# 如何检查另一个用户是否在公司层次结构中处于同一级别或更低级别?,c#,sharepoint,active-directory,user-profile,C#,Sharepoint,Active Directory,User Profile,我有这个: UserProfile prof = getUserProfile(properties.CurrentUserId); UserProfile toCheck = getUserProfile(anotherUsersId); “prof”用户必须与“toCheck”用户处于更高级别或相同级别。如果“toCheck”位于较低级别,则他/她必须位于层次结构树的同一分支上。如果他们处于同一级别,他们的经理必须是相同的 有没有一种简单的方法可以检查这一点?这里有一些方法可以帮助您:

我有这个:

UserProfile prof = getUserProfile(properties.CurrentUserId);
UserProfile toCheck = getUserProfile(anotherUsersId);
“prof”用户必须与“toCheck”用户处于更高级别或相同级别。如果“toCheck”位于较低级别,则他/她必须位于层次结构树的同一分支上。如果他们处于同一级别,他们的经理必须是相同的


有没有一种简单的方法可以检查这一点?

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

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

旁白:“同事”与此无关。他们是一组人员,通过完整的“我的网站”实现,用户可以管理自己。

一些伪代码:

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

在您的案例中,“级别”的定义是什么?一个用户的管理者要高出1级。公司里只有一位经理。所以层次结构树就像一棵真正的树,颠倒过来。我认为这是在使用Sharepoint UserProfile类(名称空间Microsoft.Office.Server.UserProfiles),我自己对此没有经验。如果不是这样,Vili需要发布其UserProfile类的代码。是的,这是一个SharePoint类。您使用的是Microsoft.Office.Server.UserProfiles命名空间还是旧的Microsoft.SharePoint.Portal命名空间?GetManager是解决方案。但这不是一个简单的方法(对我来说)需要递归。