List All Users
Retrieves a list of all users from Azure Active Directory.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Inputs
- Access Id - The access ID from the Connect node. Optional if using direct credentials.
Options
Direct Credentials (optional - alternative to using Connect node):
- Tenant Id - Azure AD tenant ID (optional if using Access ID)
- Client Id - Azure AD application client ID (optional if using Access ID)
- Client Secret - Azure AD application client secret credential (optional if using Access ID)
Output
- Result - Object containing an array of user objects in the
valueproperty. Each user object includes:id- User's unique object IDuserPrincipalName- User's principal name (email)displayName- User's display namegivenName- First namesurname- Last namejobTitle- Job titledepartment- DepartmentaccountEnabled- Whether account is enabled- And other user properties
How It Works
The List All Users node:
- Authenticates using either the access ID or direct credentials
- Sends a GET request to Microsoft Graph API to retrieve all users
- Returns a paginated list of users (default page size from Graph API)
- Result contains
valuearray with user objects
This node retrieves the first page of users. For large directories, you may need to handle pagination using the @odata.nextLink property if present in the result.
Examples
List All Users
Get all users in your organization:
// Using Connect node
access_id = message.access_id
// List All Users node executes
// Output
result = {
"value": [
{
"id": "12345678-1234-1234-1234-123456789012",
"userPrincipalName": "john.doe@contoso.onmicrosoft.com",
"displayName": "John Doe",
"jobTitle": "Senior Developer",
...
},
{
"id": "abcdef12-3456-7890-abcd-ef1234567890",
"userPrincipalName": "jane.smith@contoso.onmicrosoft.com",
"displayName": "Jane Smith",
"jobTitle": "Product Manager",
...
}
]
}
Count Total Users
Get the total number of users:
// List All Users node
access_id = message.access_id
// Count users
total_users = result.value.length
console.log("Total users: " + total_users)
Extract User Emails
Get a list of all user email addresses:
// List All Users node
// Extract emails
user_emails = []
for (user of result.value) {
user_emails.push(user.userPrincipalName)
}
console.log("User emails: " + user_emails.join(", "))
Filter Users by Department
Find all users in a specific department:
// List All Users node
// Filter by department
engineering_users = []
for (user of result.value) {
if (user.department === "Engineering") {
engineering_users.push({
name: user.displayName,
email: user.userPrincipalName,
title: user.jobTitle
})
}
}
console.log("Engineering users: " + engineering_users.length)
Find Disabled Accounts
List all disabled user accounts:
// List All Users node
// Find disabled accounts
disabled_accounts = []
for (user of result.value) {
if (!user.accountEnabled) {
disabled_accounts.push({
name: user.displayName,
email: user.userPrincipalName
})
}
}
console.log("Disabled accounts: " + disabled_accounts.length)
Export Users to CSV
Create a CSV report of all users:
// List All Users node
// Prepare CSV data
csv_data = []
csv_data.push(["Name", "Email", "Department", "Job Title", "Status"])
for (user of result.value) {
csv_data.push([
user.displayName,
user.userPrincipalName,
user.department || "N/A",
user.jobTitle || "N/A",
user.accountEnabled ? "Active" : "Disabled"
])
}
// Write CSV node
// Data: csv_data
// File: "users_report.csv"
Generate User Directory
Create a user directory with key information:
// List All Users node
// Build directory
user_directory = []
for (user of result.value) {
user_directory.push({
name: user.displayName,
email: user.userPrincipalName,
phone: user.mobilePhone || user.businessPhones?.[0] || "N/A",
department: user.department || "N/A",
office: user.officeLocation || "N/A"
})
}
// Sort by name
user_directory.sort((a, b) => a.name.localeCompare(b.name))
// Export or display
Check for Specific User
Search for a user in the list:
// List All Users node
// Search for user
search_email = "john.doe@contoso.onmicrosoft.com"
found_user = null
for (user of result.value) {
if (user.userPrincipalName.toLowerCase() === search_email.toLowerCase()) {
found_user = user
break
}
}
if (found_user) {
console.log("Found: " + found_user.displayName)
} else {
console.log("User not found")
}
Tips for Effective Use
- Result structure: Users are in the
valuearray property - Pagination: For large directories, check for
@odata.nextLinkin result - Performance: This operation can be slow for large directories
- Filtering: Apply filters after retrieving to find specific users
- Caching: Store the result if you need to reference it multiple times
- Property access: Not all users may have all properties populated
- Null checks: Always check if optional properties exist before using them
- Large datasets: Consider filtering at Graph API level for better performance
Common Errors and Solutions
"Either Client Secret with Tenant ID and Client ID, or Access ID must be provided"
Cause: Neither access ID nor complete credentials were provided.
Solution:
// Option 1: Use Connect node
access_id = message.access_id
// Option 2: Provide all credentials
tenant_id = "your-tenant-id"
client_id = "your-client-id"
// Set Client Secret option from vault
"Response Status is not OK - Insufficient privileges"
Cause: The application doesn't have permission to read users.
Solution:
- Verify your Azure AD app has
User.Read.AllorUser.ReadWrite.Allpermission - Ensure admin consent has been granted
- Check that the permission is an Application permission, not Delegated
Timeout or Slow Performance
Cause: Directory has many users and the operation takes too long.
Solution:
- Increase the node timeout setting
- Consider using Graph API filters if possible
- Process users in batches
- Cache results for reuse
Best Practices
- Error handling: Wrap List All Users in Try-Catch blocks
- Null safety: Check for null or undefined properties before accessing
- Performance: Use filtering and pagination for large directories
- Caching: Store results if needed multiple times in the flow
- Processing: Process users in batches for better performance
- Logging: Log the operation for audit purposes
- Property checks: Verify properties exist before accessing them
- Reporting: Use this for periodic user audits and reports
Related Nodes
- Connect - Establish Azure AD connection
- Get User - Get specific user details
- Create User - Create new users
- Update User - Update user properties
- Delete User - Delete users
- List All Groups - List all groups