我正在尝试使用 https://github.com/magium/active-directory 列出已分配给用户的组。我已通过并授予"组.读.全部"权限
function test()
{
session_start();
$config = [
'authentication' => [
'ad' => [
'client_id' =>,
'client_secret' =>,
'return_url' =>,
'enabled' =>,
'directory' =>
]
]
];
$request = new ZendHttpPhpEnvironmentRequest();
$ad = new MagiumActiveDirectoryActiveDirectory(
new MagiumConfigurationConfigRepositoryArrayConfigurationRepository($config),
ZendPsr7BridgePsr7ServerRequest::fromZend(new ZendHttpPhpEnvironmentRequest()),
null, null, "profile openid email offline_access User.Read Group.Read.All ");
try {
$entity = $ad->authenticate();
echo $entity->getName() . '<Br />';
echo $entity->getOid() . '<Br />';
echo $entity->getPreferredUsername() . '<Br />';
echo "<pre>";
print_r($entity);
echo "</pre>";
}
catch(MagiumActiveDirectoryInvalidRequestException $e)
{
echo "<pre>";
print_r($e);
echo "</pre>";
}
}
我有点想知道是否可以使用上面的存储库来获取用户的组而无需进行手动图形调用
对此有什么进一步的指导吗?
$request = new GuzzleHttpClient();
$result = $request->request("GET","https://graph.microsoft.com/v1.0/me/memberOf",[
'headers' => [
'Authorization' => 'Bearer ' . $entity->getAccessToken(),
'Content-Type' => 'application/json;odata.metadata=minimal;odata.streaming=true'
]
]
);
echo "<pre>";
print_r(json_decode($result->getBody()->getContents()));
echo "</pre>";
只是更容易手动调用/me/memerOf
图形 API 列表 -
https://learn.microsoft.com/en-us/graph/api/user-list-memberof?view=graph-rest-1.0&tabs=http
从问题中获取的建议路线 - https://github.com/magium/active-directory/issues/26