1. Packages
  2. Azure Active Directory (Azure AD)
  3. API Docs
  4. getUsers
Azure Active Directory (Azure AD) v5.53.1 published on Monday, Jul 1, 2024 by Pulumi

azuread.getUsers

Explore with Pulumi AI

azuread logo
Azure Active Directory (Azure AD) v5.53.1 published on Monday, Jul 1, 2024 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",
        ],
    });
    
    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/v5/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)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: azuread:index/getUsers:getUsers
      arguments:
        # arguments dictionary

    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 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.
    OnpremisesImmutableId string
    The value used to associate an on-premises Active Directory user account with their Azure AD user object.
    OnpremisesSamAccountName string
    The on-premise SAM account name of the user.
    OnpremisesUserPrincipalName string
    The on-premise user principal name of the user.
    UsageLocation string
    The usage location of the user.
    UserPrincipalName string
    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.
    OnpremisesImmutableId string
    The value used to associate an on-premises Active Directory user account with their Azure AD user object.
    OnpremisesSamAccountName string
    The on-premise SAM account name of the user.
    OnpremisesUserPrincipalName string
    The on-premise user principal name of the user.
    UsageLocation string
    The usage location of the user.
    UserPrincipalName string
    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.
    onpremisesImmutableId String
    The value used to associate an on-premises Active Directory user account with their Azure AD user object.
    onpremisesSamAccountName String
    The on-premise SAM account name of the user.
    onpremisesUserPrincipalName String
    The on-premise user principal name of the user.
    usageLocation String
    The usage location of the user.
    userPrincipalName String
    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.
    onpremisesImmutableId string
    The value used to associate an on-premises Active Directory user account with their Azure AD user object.
    onpremisesSamAccountName string
    The on-premise SAM account name of the user.
    onpremisesUserPrincipalName string
    The on-premise user principal name of the user.
    usageLocation string
    The usage location of the user.
    userPrincipalName string
    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_id str
    The value used to associate an on-premises Active Directory user account with their Azure AD user object.
    onpremises_sam_account_name str
    The on-premise SAM account name of the user.
    onpremises_user_principal_name str
    The on-premise user principal name of the user.
    usage_location str
    The usage location of the user.
    user_principal_name str
    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.
    onpremisesImmutableId String
    The value used to associate an on-premises Active Directory user account with their Azure AD user object.
    onpremisesSamAccountName String
    The on-premise SAM account name of the user.
    onpremisesUserPrincipalName String
    The on-premise user principal name of the user.
    usageLocation String
    The usage location of the user.
    userPrincipalName 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.
    azuread logo
    Azure Active Directory (Azure AD) v5.53.1 published on Monday, Jul 1, 2024 by Pulumi