Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,12 @@ try {
# Make sure the provisioner OID is set so we can pass it through to the deployment.
if (!$ProvisionerApplicationId -and !$ProvisionerApplicationOid) {
if ($context.Account.Type -eq 'User') {
# Support corp tenant and TME tenant user id lookups
$user = Get-AzADUser -Mail $context.Account.Id
if ($null -eq $user -or !$user.Id) {
$user = Get-AzADUser -UserPrincipalName $context.Account.Id
}
if ($null -eq $user -or !$user.Id) {
# HomeAccountId format is '<object id>.<tenant id>'
$userAccountId = (Get-AzContext).Account.ExtendedProperties.HomeAccountId.Split('.')[0]
if ($null -eq $userAccountId) {
throw "Failed to find entra object ID for the current user"
}
$ProvisionerApplicationOid = $user.Id
$ProvisionerApplicationOid = $userAccountId
} elseif ($context.Account.Type -eq 'ServicePrincipal') {
$sp = Get-AzADServicePrincipal -ApplicationId $context.Account.Id
$ProvisionerApplicationOid = $sp.Id
Expand Down Expand Up @@ -431,17 +428,14 @@ try {
Write-Warning "The specified TestApplicationId '$TestApplicationId' will be ignored when -ServicePrincipalAutth is not set."
}

# Support corp tenant and TME tenant user id lookups
$userAccount = (Get-AzADUser -Mail (Get-AzContext).Account.Id)
if ($null -eq $userAccount -or !$userAccount.Id) {
$userAccount = (Get-AzADUser -UserPrincipalName (Get-AzContext).Account)
}
if ($null -eq $userAccount -or !$userAccount.Id) {
$userAccountName = (Get-AzContext).Account.Id
# HomeAccountId format is '<object id>.<tenant id>'
$userAccountId = (Get-AzContext).Account.ExtendedProperties.HomeAccountId.Split('.')[0]
if ($null -eq $userAccountId) {
throw "Failed to find entra object ID for the current user"
}
$TestApplicationOid = $userAccount.Id
$TestApplicationOid = $userAccountId
$TestApplicationId = $testApplicationOid
$userAccountName = $userAccount.UserPrincipalName
Log "User authentication with user '$userAccountName' ('$TestApplicationId') will be used."
}
# If user has specified -ServicePrincipalAuth
Expand Down
Loading