azuread.getUsers
Explore with Pulumi AI
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",
    ],
});
import pulumi
import pulumi_azuread as azuread
users = azuread.get_users(user_principal_names=[
    "kat@example.com",
    "byte@example.com",
])
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
	})
}
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",
        },
    });
});
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());
    }
}
variables:
  users:
    fn::invoke:
      function: azuread:getUsers
      arguments:
        userPrincipalNames:
          - kat@example.com
          - byte@example.com
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>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]func GetUsers(ctx *Context, args *GetUsersArgs, opts ...InvokeOption) (*GetUsersResult, error)
func GetUsersOutput(ctx *Context, args *GetUsersOutputArgs, opts ...InvokeOption) GetUsersResultOutput> 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)
}public static CompletableFuture<GetUsersResult> getUsers(GetUsersArgs args, InvokeOptions options)
public static Output<GetUsersResult> getUsers(GetUsersArgs args, InvokeOptions options)
fn::invoke:
  function: azuread:index/getUsers:getUsers
  arguments:
    # arguments dictionaryThe 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 tofalse.
- 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 withignore_missing. Defaults tofalse.
- UserPrincipal List<string>Names 
- The user principal names (UPNs) of the users. - Either - return_all, or one of- user_principal_names,- object_ids,- mail_nicknames,- mails, or- employee_idsmust 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 tofalse.
- 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 withignore_missing. Defaults tofalse.
- UserPrincipal []stringNames 
- The user principal names (UPNs) of the users. - Either - return_all, or one of- user_principal_names,- object_ids,- mail_nicknames,- mails, or- employee_idsmust 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 tofalse.
- 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 withignore_missing. Defaults tofalse.
- userPrincipal List<String>Names 
- The user principal names (UPNs) of the users. - Either - return_all, or one of- user_principal_names,- object_ids,- mail_nicknames,- mails, or- employee_idsmust 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 tofalse.
- 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 withignore_missing. Defaults tofalse.
- userPrincipal string[]Names 
- The user principal names (UPNs) of the users. - Either - return_all, or one of- user_principal_names,- object_ids,- mail_nicknames,- mails, or- employee_idsmust 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 tofalse.
- 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 withignore_missing. Defaults tofalse.
- user_principal_ Sequence[str]names 
- The user principal names (UPNs) of the users. - Either - return_all, or one of- user_principal_names,- object_ids,- mail_nicknames,- mails, or- employee_idsmust 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 tofalse.
- 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 withignore_missing. Defaults tofalse.
- userPrincipal List<String>Names 
- The user principal names (UPNs) of the users. - Either - return_all, or one of- user_principal_names,- object_ids,- mail_nicknames,- mails, or- employee_idsmust 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.
- UserPrincipal List<string>Names 
- The user principal names (UPNs) of the users.
- Users
List<Pulumi.Azure AD. Outputs. Get Users User> 
- A list of users. Each userobject 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.
- UserPrincipal []stringNames 
- The user principal names (UPNs) of the users.
- Users
[]GetUsers User 
- A list of users. Each userobject 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.
- userPrincipal List<String>Names 
- The user principal names (UPNs) of the users.
- users
List<GetUsers User> 
- A list of users. Each userobject 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.
- userPrincipal string[]Names 
- The user principal names (UPNs) of the users.
- users
GetUsers User[] 
- A list of users. Each userobject 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_ Sequence[str]names 
- The user principal names (UPNs) of the users.
- users
Sequence[GetUsers User] 
- A list of users. Each userobject 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.
- userPrincipal List<String>Names 
- The user principal names (UPNs) of the users.
- users List<Property Map>
- A list of users. Each userobject provides the attributes documented below.
- ignoreMissing Boolean
- returnAll Boolean
Supporting Types
GetUsersUser  
- AccountEnabled bool
- Whether the account is enabled.
- DisplayName string
- The display name of the user.
- EmployeeId string
- The employee identifier assigned to the user by the organisation.
- Mail string
- The SMTP email address of the user.
- MailNickname string
- The email alias of the user.
- ObjectId string
- The object ID of the user.
- OnpremisesImmutable stringId 
- The value used to associate an on-premises Active Directory user account with their Azure AD user object.
- OnpremisesSam stringAccount Name 
- The on-premise SAM account name of the user.
- OnpremisesUser stringPrincipal Name 
- The on-premise user principal name of the user.
- UsageLocation string
- The usage location of the user.
- UserPrincipal stringName 
- The user principal name (UPN) of the user.
- AccountEnabled bool
- Whether the account is enabled.
- DisplayName string
- The display name of the user.
- EmployeeId string
- The employee identifier assigned to the user by the organisation.
- Mail string
- The SMTP email address of the user.
- MailNickname string
- The email alias of the user.
- ObjectId string
- The object ID of the user.
- OnpremisesImmutable stringId 
- The value used to associate an on-premises Active Directory user account with their Azure AD user object.
- OnpremisesSam stringAccount Name 
- The on-premise SAM account name of the user.
- OnpremisesUser stringPrincipal Name 
- The on-premise user principal name of the user.
- UsageLocation string
- The usage location of the user.
- UserPrincipal stringName 
- The user principal name (UPN) of the user.
- accountEnabled Boolean
- Whether the account is enabled.
- displayName String
- The display name of the user.
- employeeId String
- The employee identifier assigned to the user by the organisation.
- mail String
- The SMTP email address of the user.
- mailNickname String
- The email alias of the user.
- objectId String
- The object ID of the user.
- onpremisesImmutable StringId 
- The value used to associate an on-premises Active Directory user account with their Azure AD user object.
- onpremisesSam StringAccount Name 
- The on-premise SAM account name of the user.
- onpremisesUser StringPrincipal Name 
- The on-premise user principal name of the user.
- usageLocation String
- The usage location of the user.
- userPrincipal StringName 
- The user principal name (UPN) of the user.
- accountEnabled boolean
- Whether the account is enabled.
- displayName string
- The display name of the user.
- employeeId string
- The employee identifier assigned to the user by the organisation.
- mail string
- The SMTP email address of the user.
- mailNickname string
- The email alias of the user.
- objectId string
- The object ID of the user.
- onpremisesImmutable stringId 
- The value used to associate an on-premises Active Directory user account with their Azure AD user object.
- onpremisesSam stringAccount Name 
- The on-premise SAM account name of the user.
- onpremisesUser stringPrincipal Name 
- The on-premise user principal name of the user.
- usageLocation string
- The usage location of the user.
- userPrincipal stringName 
- The user principal name (UPN) of the user.
- account_enabled bool
- Whether the account is enabled.
- display_name str
- The display name of the user.
- employee_id str
- The employee identifier assigned to the user by the organisation.
- mail str
- The SMTP email address of the user.
- mail_nickname str
- The email alias of the user.
- object_id str
- The object ID of the user.
- onpremises_immutable_ strid 
- The value used to associate an on-premises Active Directory user account with their Azure AD user object.
- onpremises_sam_ straccount_ name 
- The on-premise SAM account name of the user.
- onpremises_user_ strprincipal_ name 
- The on-premise user principal name of the user.
- usage_location str
- The usage location of the user.
- user_principal_ strname 
- The user principal name (UPN) of the user.
- accountEnabled Boolean
- Whether the account is enabled.
- displayName String
- The display name of the user.
- employeeId String
- The employee identifier assigned to the user by the organisation.
- mail String
- The SMTP email address of the user.
- mailNickname String
- The email alias of the user.
- objectId String
- The object ID of the user.
- onpremisesImmutable StringId 
- The value used to associate an on-premises Active Directory user account with their Azure AD user object.
- onpremisesSam StringAccount Name 
- The on-premise SAM account name of the user.
- onpremisesUser StringPrincipal Name 
- The on-premise user principal name of the user.
- usageLocation String
- The usage location of the user.
- userPrincipal StringName 
- 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 azureadTerraform Provider.