简体   繁体   English

在 php 中获取 azure 广告登录用户名

[英]get azure ad login username in php

I am trying to get username when I logged in Azure ad.我在登录 Azure 广告时尝试获取用户名。 When I go https://xxxx.azurewebsites.net it redirect to azure ad.当我访问https://xxxx.azurewebsites.net 时,它会重定向到 azure 广告。 After that I want to use, that username.之后我想使用那个用户名。 But I dont know how to do it?但我不知道该怎么做? Below code didnt work.下面的代码不起作用。

I also wrote https://xxxx.azurewebsites.net/.auth/login/aad/callback but didnt work我也写了https://xxxx.azurewebsites.net/.auth/login/aad/callback但没有用

<script type="text/javascript">
        $(document).ready(function ()
        {
            $.get("https://xxxxxx.azurewebsites.net/.auth/me", function (data, status) {
                for (var key in data[0]["user_claims"]) {
                    var obj = data[0]["user_claims"][key];
                    alert(obj["typ"]);   //claim type in user_claims
                    alert(obj["val"])    //claim value in user_claims                 
                }
            });
        });
   </script>

Actually we can only do https://xxxxxx.azurewebsites.net/.auth/me when we did nothing with AAD information in our project.实际上我们只能做https://xxxxxx.azurewebsites.net/.auth/me当我们在我们的项目中对AAD信息什么都不做的时候。 在此处输入图片说明

If you integrate AAD in your project already, you can modify your code getting auth information in the backend, and show them in your client.如果您已经将 AAD 集成到您的项目中,您可以修改您的代码以在后端获取身份验证信息,并在您的客户端中显示它们。

There is a issue similar to yours, you can have a look at this .有一个和你类似的问题,你可以看看这个

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

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