简体   繁体   English

使用户进入Azure活动目录

[英]To get users in azure active directory

I am using Graph API calls to get the details of all users in the organization. 我正在使用Graph API调用来获取组织中所有用户的详细信息。

function string getusers(){
        var client1 = new RestClient("https://graph.microsoft.com/v1.0/users");
        var request1 = new RestRequest(Method.GET);
        request1.AddHeader("Content-Type", "application/json");
        request1.AddHeader("Authorization", "Bearer " + token);

        request1.AddHeader("Cache-Control", "no");
        IRestResponse response1 = client1.Execute(request1);
        return response1.Content.toString();
}

I am using this API call but it is returning an error related to authentication: 我正在使用此API调用,但它返回与身份验证相关的错误:

 {
    "error": {
        "code": "Authorization_RequestDenied",
        "message": "Insufficient privileges to complete the operation.",
        "innerError": {
            "request-id": "16a2e8d3-a93d-4197-9ef9-8b67a705f0e5",
            "date": "2018-02-17T19:51:46"
        }
    }
}

But as I change 但是随着我的改变

var client1 = new RestClient("https://graph.microsoft.com/v1.0/users");

to

var client1 = new RestClient("https://graph.microsoft.com/v1.0/me");

Then it returns all details about currently logged in user. 然后,它返回有关当前登录用户的所有详细信息。

It is really complex for me to solve it without any help or reference. 在没有任何帮助或参考的情况下,解决它真的很复杂。

It looks like you have requested the user.read scope. 似乎您已请求user.read范围。 This will allow you to read the current user's profile ( /me ) but not other user's within the tenant ( /users ). 这将允许您读取当前用户的配置文件( /me ),但不能读取租户中的其他用户( /users )。

You need to also request the User.ReadBasic.All to your authentication request. 您还需要向身份验证请求请求User.ReadBasic.All This will allow you to read basic profile information for any user in the tenant. 这将允许您读取租户中任何用户的基本配置文件信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM