1. Packages
  2. Azure Active Directory (Azure AD)
  3. API Docs
  4. getUsers
Azure Active Directory (Azure AD) v6.4.0 published on Monday, Apr 7, 2025 by Pulumi

azuread.getUsers

Explore with Pulumi AI

Azure Active Directory (Azure AD) v6.4.0 published on Monday, Apr 7, 2025 by Pulumi

Gets basic information for multiple Azure Active Directory users.

API Permissions

The following API permissions are required in order to use this data source.

When authenticated with a service principal, this data source requires one of the following application roles: User.ReadBasic.All, User.Read.All or Directory.Read.All

When authenticated with a user principal, this data source does not require any additional roles.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azuread from "@pulumi/azuread";

const users = azuread.getUsers({
    userPrincipalNames: [
        "kat@example.com",
        "byte@example.com",
    ],
});
Copy
import pulumi
import pulumi_azuread as azuread

users = azuread.get_users(user_principal_names=[
    "kat@example.com",
    "byte@example.com",
])
Copy
package main

import (
	"github.com/pulumi/pulumi-azuread/sdk/v6/go/azuread"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := azuread.GetUsers(ctx, &azuread.GetUsersArgs{
			UserPrincipalNames: []string{
				"kat@example.com",
				"byte@example.com",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureAD = Pulumi.AzureAD;

return await Deployment.RunAsync(() => 
{
    var users = AzureAD.GetUsers.Invoke(new()
    {
        UserPrincipalNames = new[]
        {
            "kat@example.com",
            "byte@example.com",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azuread.AzureadFunctions;
import com.pulumi.azuread.inputs.GetUsersArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var users = AzureadFunctions.getUsers(GetUsersArgs.builder()
            .userPrincipalNames(            
                "kat@example.com",
                "byte@example.com")
            .build());

    }
}
Copy
variables:
  users:
    fn::invoke:
      function: azuread:getUsers
      arguments:
        userPrincipalNames:
          - kat@example.com
          - byte@example.com
Copy

Using getUsers

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getUsers(args: GetUsersArgs, opts?: InvokeOptions): Promise<GetUsersResult>
function getUsersOutput(args: GetUsersOutputArgs, opts?: InvokeOptions): Output<GetUsersResult>
Copy
def get_users(employee_ids: Optional[Sequence[str]] = None,
              ignore_missing: Optional[bool] = None,
              mail_nicknames: Optional[Sequence[str]] = None,
              mails: Optional[Sequence[str]] = None,
              object_ids: Optional[Sequence[str]] = None,
              return_all: Optional[bool] = None,
              user_principal_names: Optional[Sequence[str]] = None,
              opts: Optional[InvokeOptions] = None) -> GetUsersResult
def get_users_output(employee_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
              ignore_missing: Optional[pulumi.Input[bool]] = None,
              mail_nicknames: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
              mails: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
              object_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
              return_all: Optional[pulumi.Input[bool]] = None,
              user_principal_names: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
              opts: Optional[InvokeOptions] = None) -> Output[GetUsersResult]
Copy
func GetUsers(ctx *Context, args *GetUsersArgs, opts ...InvokeOption) (*GetUsersResult, error)
func GetUsersOutput(ctx *Context, args *GetUsersOutputArgs, opts ...InvokeOption) GetUsersResultOutput
Copy

> Note: This function is named GetUsers in the Go SDK.

public static class GetUsers 
{
    public static Task<GetUsersResult> InvokeAsync(GetUsersArgs args, InvokeOptions? opts = null)
    public static Output<GetUsersResult> Invoke(GetUsersInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetUsersResult> getUsers(GetUsersArgs args, InvokeOptions options)
public static Output<GetUsersResult> getUsers(GetUsersArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: azuread:index/getUsers:getUsers
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

EmployeeIds List<string>
The employee identifiers assigned to the users by the organisation.
IgnoreMissing bool
Ignore missing users and return users that were found. The data source will still fail if no users are found. Cannot be specified with return_all. Defaults to false.
MailNicknames List<string>
The email aliases of the users.
Mails List<string>
The SMTP email addresses of the users.
ObjectIds List<string>
The object IDs of the users.
ReturnAll bool
When true, the data source will return all users. Cannot be used with ignore_missing. Defaults to false.
UserPrincipalNames List<string>

The user principal names (UPNs) of the users.

Either return_all, or one of user_principal_names, object_ids, mail_nicknames, mails, or employee_ids must be specified. These may be specified as an empty list, in which case no results will be returned.

EmployeeIds []string
The employee identifiers assigned to the users by the organisation.
IgnoreMissing bool
Ignore missing users and return users that were found. The data source will still fail if no users are found. Cannot be specified with return_all. Defaults to false.
MailNicknames []string
The email aliases of the users.
Mails []string
The SMTP email addresses of the users.
ObjectIds []string
The object IDs of the users.
ReturnAll bool
When true, the data source will return all users. Cannot be used with ignore_missing. Defaults to false.
UserPrincipalNames []string

The user principal names (UPNs) of the users.

Either return_all, or one of user_principal_names, object_ids, mail_nicknames, mails, or employee_ids must be specified. These may be specified as an empty list, in which case no results will be returned.

employeeIds List<String>
The employee identifiers assigned to the users by the organisation.
ignoreMissing Boolean
Ignore missing users and return users that were found. The data source will still fail if no users are found. Cannot be specified with return_all. Defaults to false.
mailNicknames List<String>
The email aliases of the users.
mails List<String>
The SMTP email addresses of the users.
objectIds List<String>
The object IDs of the users.
returnAll Boolean
When true, the data source will return all users. Cannot be used with ignore_missing. Defaults to false.
userPrincipalNames List<String>

The user principal names (UPNs) of the users.

Either return_all, or one of user_principal_names, object_ids, mail_nicknames, mails, or employee_ids must be specified. These may be specified as an empty list, in which case no results will be returned.

employeeIds string[]
The employee identifiers assigned to the users by the organisation.
ignoreMissing boolean
Ignore missing users and return users that were found. The data source will still fail if no users are found. Cannot be specified with return_all. Defaults to false.
mailNicknames string[]
The email aliases of the users.
mails string[]
The SMTP email addresses of the users.
objectIds string[]
The object IDs of the users.
returnAll boolean
When true, the data source will return all users. Cannot be used with ignore_missing. Defaults to false.
userPrincipalNames string[]

The user principal names (UPNs) of the users.

Either return_all, or one of user_principal_names, object_ids, mail_nicknames, mails, or employee_ids must be specified. These may be specified as an empty list, in which case no results will be returned.

employee_ids Sequence[str]
The employee identifiers assigned to the users by the organisation.
ignore_missing bool
Ignore missing users and return users that were found. The data source will still fail if no users are found. Cannot be specified with return_all. Defaults to false.
mail_nicknames Sequence[str]
The email aliases of the users.
mails Sequence[str]
The SMTP email addresses of the users.
object_ids Sequence[str]
The object IDs of the users.
return_all bool
When true, the data source will return all users. Cannot be used with ignore_missing. Defaults to false.
user_principal_names Sequence[str]

The user principal names (UPNs) of the users.

Either return_all, or one of user_principal_names, object_ids, mail_nicknames, mails, or employee_ids must be specified. These may be specified as an empty list, in which case no results will be returned.

employeeIds List<String>
The employee identifiers assigned to the users by the organisation.
ignoreMissing Boolean
Ignore missing users and return users that were found. The data source will still fail if no users are found. Cannot be specified with return_all. Defaults to false.
mailNicknames List<String>
The email aliases of the users.
mails List<String>
The SMTP email addresses of the users.
objectIds List<String>
The object IDs of the users.
returnAll Boolean
When true, the data source will return all users. Cannot be used with ignore_missing. Defaults to false.
userPrincipalNames List<String>

The user principal names (UPNs) of the users.

Either return_all, or one of user_principal_names, object_ids, mail_nicknames, mails, or employee_ids must be specified. These may be specified as an empty list, in which case no results will be returned.

getUsers Result

The following output properties are available:

EmployeeIds List<string>
The employee identifiers assigned to the users by the organisation.
Id string
The provider-assigned unique ID for this managed resource.
MailNicknames List<string>
The email aliases of the users.
Mails List<string>
The SMTP email addresses of the users.
ObjectIds List<string>
The object IDs of the users.
UserPrincipalNames List<string>
The user principal names (UPNs) of the users.
Users List<Pulumi.AzureAD.Outputs.GetUsersUser>
A list of users. Each user object provides the attributes documented below.
IgnoreMissing bool
ReturnAll bool
EmployeeIds []string
The employee identifiers assigned to the users by the organisation.
Id string
The provider-assigned unique ID for this managed resource.
MailNicknames []string
The email aliases of the users.
Mails []string
The SMTP email addresses of the users.
ObjectIds []string
The object IDs of the users.
UserPrincipalNames []string
The user principal names (UPNs) of the users.
Users []GetUsersUser
A list of users. Each user object provides the attributes documented below.
IgnoreMissing bool
ReturnAll bool
employeeIds List<String>
The employee identifiers assigned to the users by the organisation.
id String
The provider-assigned unique ID for this managed resource.
mailNicknames List<String>
The email aliases of the users.
mails List<String>
The SMTP email addresses of the users.
objectIds List<String>
The object IDs of the users.
userPrincipalNames List<String>
The user principal names (UPNs) of the users.
users List<GetUsersUser>
A list of users. Each user object provides the attributes documented below.
ignoreMissing Boolean
returnAll Boolean
employeeIds string[]
The employee identifiers assigned to the users by the organisation.
id string
The provider-assigned unique ID for this managed resource.
mailNicknames string[]
The email aliases of the users.
mails string[]
The SMTP email addresses of the users.
objectIds string[]
The object IDs of the users.
userPrincipalNames string[]
The user principal names (UPNs) of the users.
users GetUsersUser[]
A list of users. Each user object provides the attributes documented below.
ignoreMissing boolean
returnAll boolean
employee_ids Sequence[str]
The employee identifiers assigned to the users by the organisation.
id str
The provider-assigned unique ID for this managed resource.
mail_nicknames Sequence[str]
The email aliases of the users.
mails Sequence[str]
The SMTP email addresses of the users.
object_ids Sequence[str]
The object IDs of the users.
user_principal_names Sequence[str]
The user principal names (UPNs) of the users.
users Sequence[GetUsersUser]
A list of users. Each user object provides the attributes documented below.
ignore_missing bool
return_all bool
employeeIds List<String>
The employee identifiers assigned to the users by the organisation.
id String
The provider-assigned unique ID for this managed resource.
mailNicknames List<String>
The email aliases of the users.
mails List<String>
The SMTP email addresses of the users.
objectIds List<String>
The object IDs of the users.
userPrincipalNames List<String>
The user principal names (UPNs) of the users.
users List<Property Map>
A list of users. Each user object provides the attributes documented below.
ignoreMissing Boolean
returnAll Boolean

Supporting Types

GetUsersUser

AccountEnabled This property is required. bool
Whether the account is enabled.
DisplayName This property is required. string
The display name of the user.
EmployeeId This property is required. string
The employee identifier assigned to the user by the organisation.
Mail This property is required. string
The SMTP email address of the user.
MailNickname This property is required. string
The email alias of the user.
ObjectId This property is required. string
The object ID of the user.
OnpremisesImmutableId This property is required. string
The value used to associate an on-premises Active Directory user account with their Azure AD user object.
OnpremisesSamAccountName This property is required. string
The on-premise SAM account name of the user.
OnpremisesUserPrincipalName This property is required. string
The on-premise user principal name of the user.
UsageLocation This property is required. string
The usage location of the user.
UserPrincipalName This property is required. string
The user principal name (UPN) of the user.
AccountEnabled This property is required. bool
Whether the account is enabled.
DisplayName This property is required. string
The display name of the user.
EmployeeId This property is required. string
The employee identifier assigned to the user by the organisation.
Mail This property is required. string
The SMTP email address of the user.
MailNickname This property is required. string
The email alias of the user.
ObjectId This property is required. string
The object ID of the user.
OnpremisesImmutableId This property is required. string
The value used to associate an on-premises Active Directory user account with their Azure AD user object.
OnpremisesSamAccountName This property is required. string
The on-premise SAM account name of the user.
OnpremisesUserPrincipalName This property is required. string
The on-premise user principal name of the user.
UsageLocation This property is required. string
The usage location of the user.
UserPrincipalName This property is required. string
The user principal name (UPN) of the user.
accountEnabled This property is required. Boolean
Whether the account is enabled.
displayName This property is required. String
The display name of the user.
employeeId This property is required. String
The employee identifier assigned to the user by the organisation.
mail This property is required. String
The SMTP email address of the user.
mailNickname This property is required. String
The email alias of the user.
objectId This property is required. String
The object ID of the user.
onpremisesImmutableId This property is required. String
The value used to associate an on-premises Active Directory user account with their Azure AD user object.
onpremisesSamAccountName This property is required. String
The on-premise SAM account name of the user.
onpremisesUserPrincipalName This property is required. String
The on-premise user principal name of the user.
usageLocation This property is required. String
The usage location of the user.
userPrincipalName This property is required. String
The user principal name (UPN) of the user.
accountEnabled This property is required. boolean
Whether the account is enabled.
displayName This property is required. string
The display name of the user.
employeeId This property is required. string
The employee identifier assigned to the user by the organisation.
mail This property is required. string
The SMTP email address of the user.
mailNickname This property is required. string
The email alias of the user.
objectId This property is required. string
The object ID of the user.
onpremisesImmutableId This property is required. string
The value used to associate an on-premises Active Directory user account with their Azure AD user object.
onpremisesSamAccountName This property is required. string
The on-premise SAM account name of the user.
onpremisesUserPrincipalName This property is required. string
The on-premise user principal name of the user.
usageLocation This property is required. string
The usage location of the user.
userPrincipalName This property is required. string
The user principal name (UPN) of the user.
account_enabled This property is required. bool
Whether the account is enabled.
display_name This property is required. str
The display name of the user.
employee_id This property is required. str
The employee identifier assigned to the user by the organisation.
mail This property is required. str
The SMTP email address of the user.
mail_nickname This property is required. str
The email alias of the user.
object_id This property is required. str
The object ID of the user.
onpremises_immutable_id This property is required. str
The value used to associate an on-premises Active Directory user account with their Azure AD user object.
onpremises_sam_account_name This property is required. str
The on-premise SAM account name of the user.
onpremises_user_principal_name This property is required. str
The on-premise user principal name of the user.
usage_location This property is required. str
The usage location of the user.
user_principal_name This property is required. str
The user principal name (UPN) of the user.
accountEnabled This property is required. Boolean
Whether the account is enabled.
displayName This property is required. String
The display name of the user.
employeeId This property is required. String
The employee identifier assigned to the user by the organisation.
mail This property is required. String
The SMTP email address of the user.
mailNickname This property is required. String
The email alias of the user.
objectId This property is required. String
The object ID of the user.
onpremisesImmutableId This property is required. String
The value used to associate an on-premises Active Directory user account with their Azure AD user object.
onpremisesSamAccountName This property is required. String
The on-premise SAM account name of the user.
onpremisesUserPrincipalName This property is required. String
The on-premise user principal name of the user.
usageLocation This property is required. String
The usage location of the user.
userPrincipalName This property is required. String
The user principal name (UPN) of the user.

Package Details

Repository
Azure Active Directory (Azure AD) pulumi/pulumi-azuread
License
Apache-2.0
Notes
This Pulumi package is based on the azuread Terraform Provider.
Azure Active Directory (Azure AD) v6.4.0 published on Monday, Apr 7, 2025 by Pulumi