Skip to main content

Get User

Retrieves detailed information about a specific user 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.
info

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.
  • User Id - User ID (object ID) or user principal name (email) of the user to retrieve. Examples:
    • User ID: 12345678-1234-1234-1234-123456789012
    • User Principal Name: john.doe@contoso.onmicrosoft.com

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 - User object containing detailed user information including:
    • id - User's unique object ID
    • userPrincipalName - User's principal name (email)
    • displayName - User's display name
    • givenName - First name
    • surname - Last name
    • jobTitle - Job title
    • department - Department
    • officeLocation - Office location
    • mobilePhone - Mobile phone number
    • businessPhones - Business phone numbers
    • mail - Email address
    • accountEnabled - Whether account is enabled
    • And many other properties

How It Works

The Get User node:

  1. Authenticates using either the access ID or direct credentials
  2. Sends a GET request to Microsoft Graph API for the specified user
  3. Returns the complete user object with all properties
  4. Supports lookup by either user ID or user principal name

Examples

Get User by User Principal Name

Retrieve user information using email address:

// Using Connect node
access_id = message.access_id
user_id = "john.doe@contoso.onmicrosoft.com"

// Get User node executes

// Output
result = {
"id": "12345678-1234-1234-1234-123456789012",
"userPrincipalName": "john.doe@contoso.onmicrosoft.com",
"displayName": "John Doe",
"givenName": "John",
"surname": "Doe",
"jobTitle": "Senior Developer",
"department": "Engineering",
"accountEnabled": true,
...
}

Get User by Object ID

Retrieve user using their unique ID:

access_id = message.access_id
user_id = "12345678-1234-1234-1234-123456789012"

// Returns same user object with all properties

Check User Account Status

Verify if a user account is enabled:

// Get User node
user_id = "john.doe@contoso.onmicrosoft.com"

// Check account status
if (result.accountEnabled) {
// Account is active
console.log("User account is enabled")
} else {
// Account is disabled
console.log("User account is disabled")
}

Extract User Properties

Get specific user information for processing:

// Get User node
user_id = "john.doe@contoso.onmicrosoft.com"

// Extract needed properties
user_info = {
name: result.displayName,
email: result.userPrincipalName,
department: result.department,
phone: result.mobilePhone,
location: result.officeLocation
}

// Use extracted data
console.log("User: " + user_info.name)
console.log("Department: " + user_info.department)

Verify User Exists Before Update

Check if user exists before performing operations:

try {
// Get User node
user_id = "newuser@contoso.onmicrosoft.com"

// User exists, can proceed with update
console.log("Found user: " + result.displayName)

} catch (error) {
// User doesn't exist
console.log("User not found, creating new user...")
// Create User node
}

Bulk User Information Retrieval

Get information for multiple users:

// List of user emails
user_emails = [
"user1@contoso.onmicrosoft.com",
"user2@contoso.onmicrosoft.com",
"user3@contoso.onmicrosoft.com"
]

user_details = []

// Loop through users
for (email of user_emails) {
// Get User node
// User Id: email

// Store user info
user_details.push({
email: result.userPrincipalName,
name: result.displayName,
department: result.department
})
}

// Export to CSV or process further

Tips for Effective Use

  • Flexible lookup: You can use either user ID or user principal name
  • Error handling: Use Try-Catch to handle users that don't exist
  • Property access: Access any user property from the result object
  • Account verification: Check accountEnabled before performing operations
  • Caching: Store user information if you need it multiple times
  • Case sensitivity: User principal names are not case-sensitive
  • Performance: Getting a single user is faster than listing all users

Common Errors and Solutions

"User Id cannot be empty"

Cause: The User Id input was not provided.

Solution: Provide a valid user ID or user principal name:

// By email
user_id = "john.doe@contoso.onmicrosoft.com"

// By object ID
user_id = "12345678-1234-1234-1234-123456789012"

"Response Status is not OK - User not found"

Cause: No user exists with the specified ID or principal name.

Solution:

  • Verify the user ID or email is correct
  • Check for typos in the email address
  • Use List All Users to find available users
  • Handle the error with Try-Catch if user might not exist
try {
// Get User node
user_id = "unknown@contoso.onmicrosoft.com"
} catch (error) {
console.log("User not found: " + user_id)
// Handle accordingly
}

"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

"Invalid user ID format"

Cause: User ID is not in correct GUID format.

Solution: Use proper format:

// Valid formats
user_id = "12345678-1234-1234-1234-123456789012" // GUID
user_id = "user@domain.onmicrosoft.com" // UPN

// Invalid format
user_id = "john.doe" // Not a valid identifier

Best Practices

  1. Error handling: Always wrap Get User in Try-Catch for production code
  2. Efficient lookups: Use user principal name when you have the email
  3. Property validation: Check if properties exist before accessing them
  4. Caching: Store user data if needed multiple times in the same flow
  5. Logging: Log user lookups for audit trails
  6. Performance: Don't repeatedly get the same user; store the result
  7. Security: Don't log sensitive user information
  8. Null checks: Verify properties are not null before using them