Hello community,
I am trying to get the identity of the caller of a New-PSUEndpoint. Something like this
New-PSUEndpoint -Url "/resabc" -Endpoint {
param(
$User
)
$UserName = ($User.Identity.Name)
$UserName = $UserName.Split('\')[1]
# do something with $UserName
}
I use this in a custom role:
param(
$User
)
$UserName = ($User.Identity.Name)
$UserName = $UserName.Split('\')[1]
$IsMember = $false
$ADGroup = "MyADGroup"
$Users = Get-ADGroupMember -Identity $ADGroup -Recursive | Select SamAccountName
$Users | ForEach-Object {
If($_.SamAccountName -eq $UserName) {
$IsMember = $true
}
}
$IsMember
The parameter $User works just fine there but has no effect/value when used in New-PSUEndpoint.
I’ve configured PSU with Windows Authentication outside of IIS (Security - PowerShell Universal).
My goal is to execute actions in the code of the endpoint based on the user identity. I do not want the users to have to somehow provide their username. It should come with a request like this
Invoke-RestMethod http://servername.xy.com:5000/resabc
I’m assuming there is a simple paramater/variable/whatever to get the caller identity? I couldn’t find anything in this forum.
Thanks for any help on that!
Product: PowerShell Universal
Version: 1.5.13