Azure AD-Graph API请求取消所有部门 [英] Azure AD - Graph API request to pull all departments

查看:56
本文介绍了Azure AD-Graph API请求取消所有部门的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows Graph API测试一些东西,并连接到Azure AD.到目前为止,我已经能够提取给定用户对象ID的用户信息.这很棒,因为它显示了部门,而这正是我要查找的.但是,我可以打一个电话,列出当前AD中的所有部门吗?我需要将它们全部拉出,以便可以看到定义的内容,并在程序中添加逻辑以允许某些部门访问某些区域.

I'm testing some things out using the Windows Graph API, connecting to an Azure AD. So far, I am able to pull the User information for a given user object id. This is great, as it shows the Department and that is what I'm wanting to find. However, it there a call I can make that will list out ALL Departments currently in the AD? I need to pull all of them so I can see what is defined, and add logic to my program to allow certain departments access to certain areas.

谢谢!

推荐答案

您一次只能获得具有相同租户ID的部门.得到这样的部门代码:

You once only get the departments in the identical tenant id. Getting department code like this:

  try
        {
            List<IUser> users = activeDirectoryClient.Users.ExecuteAsync().Result.CurrentPage.ToList();
            List<string> departmentlist = new List<string>();
            var i = 0;
            foreach (IUser user in users)
            {
               if (user.Department != null)
                {
                    string depName = user.Department.ToString();
                     departmentlist.Add(depName);
                    Console.WriteLine("UserDepartmentName:{0}", departmentlist[i]);
                    i++;
                }

             }
        }

        catch (Exception e)
        {
            Console.WriteLine("\nError getting department {0} {1}",
                e.Message, e.InnerException != null ? e.InnerException.Message : "");
        }

这篇关于Azure AD-Graph API请求取消所有部门的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆