User enumeration
Unauthenticated
Spray!
With o365enum https://github.com/gremwell/o365enum
OmniSpray https://github.com/0xZDH/Omnispray
Authenticated
AZ CLI
Get all users
Az Powershell get modules:
Install-Module -Name Az -Repository PSGallery -Force
Import-Module -Name Az
Install-Module -Name Microsoft.Graph -Scope CurrentUser -AllowClobber -Force
Import-Module -Name Microsoft.Graph
Dump all users:
List admin users
Search user attributes for strings
Get users from Entra ID
Get synced users from on-prem
Get groups where the user is a member
Get roles assigned to the user in Azure (NOT in Entra ID)
az role assignment list --include-inherited --include-groups --include-classic-administrators true --assignee <email>
Get ALL roles assigned in Azure in the current subscription (NOT in Entra ID)
API
Get bearer token
export TOKEN=$(az account get-access-token --resource https://graph.microsoft.com/ --query accessToken -o tsv)
Get users
curl -X GET "https://graph.microsoft.com/v1.0/users" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" | jq
Get EntraID roles assigned to user
curl -X GET "https://graph.microsoft.com/beta/rolemanagement/directory/transitiveRoleAssignments?\$count=true&\$filter=principalId%20eq%20'86b10631-ff01-4e73-a031-29e505565caa'" \
-H "Authorization: Bearer $TOKEN" \
-H "ConsistencyLevel: eventual" \
-H "Content-Type: application/json" | jq
Get role details
curl -X GET "https://graph.microsoft.com/beta/roleManagement/directory/roleDefinitions/cf1c38e5-3621-4004-a7cb-879624dced7c" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" | jq
User properties to gain context
With GraphRunner.ps1
Validate enabled users
az ad user list --query "[?givenName=='user1' || givenName=='user2' || givenName=='user3'].{Name:displayName, UPN:userPrincipalName, JobTitle:jobTitle}" -o table
Get users object ID
Find role assignment.
get tenantid