Skip to content

Commit 8e71041

Browse files
committed
Add username to TAP response
1 parent 1efed26 commit 8e71041

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ExecCreateTAP.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,28 @@ Function Invoke-ExecCreateTAP {
1919
$UserID = $Request.Query.ID ?? $Request.Body.ID
2020

2121
try {
22-
$Result = New-CIPPTAP -userid $UserID -TenantFilter $TenantFilter -APIName $APIName -Headers $Headers
22+
$TAPResult = New-CIPPTAP -userid $UserID -TenantFilter $TenantFilter -APIName $APIName -Headers $Headers
23+
24+
# Create results array with both TAP and UserID as separate items
25+
$Results = @(
26+
$TAPResult,
27+
@{
28+
resultText = "User ID: $UserID"
29+
copyField = $UserID
30+
state = 'success'
31+
}
32+
)
33+
2334
$StatusCode = [HttpStatusCode]::OK
2435
} catch {
25-
$Result = Get-NormalizedError -message $($_.Exception.Message)
36+
$Results = Get-NormalizedError -message $($_.Exception.Message)
2637
$StatusCode = [HttpStatusCode]::InternalServerError
2738
}
2839

2940
# Associate values to output bindings by calling 'Push-OutputBinding'.
3041
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
3142
StatusCode = $StatusCode
32-
Body = @{'Results' = $Result }
43+
Body = @{'Results' = $Results }
3344
})
3445

3546
}

Modules/CIPPCore/Public/New-CIPPTAP.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function New-CIPPTAP {
1111
$GraphRequest = New-GraphPostRequest -uri "https://graph.microsoft.com/beta/users/$($userid)/authentication/temporaryAccessPassMethods" -tenantid $TenantFilter -type POST -body '{}' -verbose
1212
Write-LogMessage -headers $Headers -API $APIName -message "Created Temporary Access Password (TAP) for $userid" -Sev 'Info' -tenant $TenantFilter
1313
return @{
14-
resultText = "The TAP for this user is $($GraphRequest.temporaryAccessPass) - This TAP is usable for the next $($GraphRequest.LifetimeInMinutes) minutes"
14+
resultText = "The TAP for $userid is $($GraphRequest.temporaryAccessPass) - This TAP is usable for the next $($GraphRequest.LifetimeInMinutes) minutes"
15+
userid = $userid
1516
copyField = $GraphRequest.temporaryAccessPass
1617
temporaryAccessPass = $GraphRequest.temporaryAccessPass
1718
lifetimeInMinutes = $GraphRequest.LifetimeInMinutes

0 commit comments

Comments
 (0)