【问题标题】:How to get a User's Group from Azure Active Directory after Authentication身份验证后如何从 Azure Active Directory 获取用户组
【发布时间】:2019-11-20 17:11:32
【问题描述】:

在我的天蓝色活动目录中注册应用程序后,我可以在回调中获取用户:

    object(Magium\ActiveDirectory\Entity)#262 (1) {
  ["data":protected]=>
  array(16) {
    ["aud"]=> string(36) "xxxxxxxxxxxxxxxxxxxx"
    ["iss"]=> string(75) "https://login.microsoftonline.com/xxxxxxxxxxxxxxxxxxxx/v2.0"
    ["iat"]=> int(xxxxxxxxxxxxxxxxxxxx)
    ["nbf"]=> int(xxxxxxxxxxxxxxxxxxxx)
    ["exp"]=> int(xxxxxxxxxxxxxxxxxxxx)
    ["aio"]=> string(140) "xxxxxxxxxxxxxxxxxxxx"
    ["email"]=> string(20) "xxxxxxxxxxxxxxxxxxxx@xxxxxxxxxxxxxxxxxxxx.com"
    ["idp"]=> string(61) "https://sts.windows.net/xxxxxxxxxxxxxxxxxxxx/"
    ["name"]=> string(13) "xxxxxxxxxxxxxxxxxxxx"
    ["oid"]=> string(36) "xxxxxxxxxxxxxxxxxxxx"
    ["preferred_username"]=> string(20) "xxxxxxxxxxxxxxxxxxxx@xxxxxxxxxxxxxxxxxxxx.com"
    ["sub"]=> string(43) "xxxxxxxxxxxxxxxxxxxx"
    ["tid"]=> string(36) "xxxxxxxxxxxxxxxxxxxx"
    ["uti"]=> string(22) "xxxxxxxxxxxxxxxxxxxx"
    ["ver"]=> string(3) "2.0"
    ["access_token"]=> string(1910) "xxxxxxxxxxxxxxxxxxxx"
  }
}

但是我如何访问我在我的天蓝色活动目录中声明的他所属的组? ps:获取用户的代码是这样的:

    @php
session_start();



$config = [
    'authentication' => [
    'ad' => [
        'client_id' => 'xxxxxxx',
        'client_secret' => 'xxxxxxx',
        'enabled' => 'yes',
        'directory' => "xxxxxxx",
        'return_url' => 'xxxxxxx'

        ]
    ]
];

$request = new \Zend\Http\PhpEnvironment\Request();

$ad = new \Magium\ActiveDirectory\ActiveDirectory(
    new \Magium\Configuration\Config\Repository\ArrayConfigurationRepository($config),
    Zend\Psr7Bridge\Psr7ServerRequest::fromZend(new \Zend\Http\PhpEnvironment\Request())
);

$entity = $ad->authenticate();
echo $entity->getName() . '<Br />';
echo $entity->getPreferredUsername() . '<Br />';
@endphp

我点击了 Azure Active Directory-> 组 -> 创建组 -> 添加用户 -> 完成。 这就是我创建组的方式。 但是在我对用户的回调中,我无法让它工作。 我完全无能为力,请帮忙。 非常感谢你们!

【问题讨论】:

    标签: php laravel azure-active-directory


    【解决方案1】:

    您正在寻找似乎不存在的 memberOf 属性。如果你使用 openLDAP,memberof 属性默认是隐藏的。检查该设置一次。还要确保该属性允许匿名访问。

    【讨论】:

    • 打扰一下,请问什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-29
    • 2017-03-22
    • 1970-01-01
    • 2015-10-14
    • 2015-01-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多