Within an App I am trying to capture the User who is logged in to create an audit log of certain actions that the app does. but All I seem to get is the service account that PSU is running as.
can anyone point me in the right Direction?
Recommended Answer
@deroppi
Is this documented anywhere? How did you know what was in the $user variable or the $ClaimsPrincipal?
I feel like I'm missing out on some big book of documentation
Nevermind….. Finally got it working
Can you share the answer?
isn’t that just the $User variable?
And anything else should be in $claimsPrincipal.
new-UDPage -Content {
$columns = @(
New-UDTableColumn -Property Name
New-UDTableColumn -Property Value
)
$var = @()
$var += @{name = "User"; value = $User }
$var += @{name = "Roles"; value = $Roles -join "," }
$var += @{name = "PSUComputerName"; value = $PSUComputerName }
$var += @{name = "$($ClaimsPrincipal.identity)"; value = ($ClaimsPrincipal.identity.name) }
foreach ($item in $ClaimsPrincipal.claims) {
$var += @{name = "$( ($item.type -split "claims")[-1] )"; value = "$($item.value)" }
}
New-UDTable -Data $var -Columns $columns -Title "logged on user account claims"
} -Title "Home & CLAIMS" -Name "DEV HOME" -Icon @{ type='icon'; icon = 'igloo' }isn’t that just the $User variable?
And anything else should be in $claimsPrincipal.
new-UDPage -Content {
$columns = @(
New-UDTableColumn -Property Name
New-UDTableColumn -Property Value
)
$var = @()
$var += @{name = "User"; value = $User }
$var += @{name = "Roles"; value = $Roles -join "," }
$var += @{name = "PSUComputerName"; value = $PSUComputerName }
$var += @{name = "$($ClaimsPrincipal.identity)"; value = ($ClaimsPrincipal.identity.name) }
foreach ($item in $ClaimsPrincipal.claims) {
$var += @{name = "$( ($item.type -split "claims")[-1] )"; value = "$($item.value)" }
}
New-UDTable -Data $var -Columns $columns -Title "logged on user account claims"
} -Title "Home & CLAIMS" -Name "DEV HOME" -Icon @{ type='icon'; icon = 'igloo' }
@deroppi
Is this documented anywhere? How did you know what was in the $user variable or the $ClaimsPrincipal?
I feel like I'm missing out on some big book of documentation
@bcaydelotte The session expired trigger is very reliable, even if delayed. It provides the identity as well as the IP address. If you don't want to clutter your dashboard, this is a solid option, in my opinion.
@deroppi
Is this documented anywhere? How did you know what was in the $user variable or the $ClaimsPrincipal?
I feel like I'm missing out on some big book of documentation
Well now I feel silly, I didn't scroll down enough.
Thank you!