Hi,
I’m trying to collect the username of the user when they have been authorised through my IDP (SAML2) but I can’t get it. User login just fine but I want to collect the username to use New-PSUAuthorizationClaim
Anyone that know why? I have tried almost everything I can think of so far even this:
$Parameters = @{
Type = "Saml2"
CallbackPath = "https://$($HostFQDN)/"
MetadataAddress = "xxx"
EntityId = "https://$($HostFQDN)/sp"
IdentityProviderEntityId = "xxx"
SingleSignOnServiceUrl = "xxx"
ScriptBlock = {
New-PSUAuthenticationResult -Success
if ($Null -ne $User.Identity.Name) {
$UserName = ($User.Identity.Name)
$UserName = $UserName.Split('\') | Select-Object -Last 1
}
if ($Null -ne $Credential.UserName) {
$UserOne = $Credential.UserName
}
if ($Null -ne $User) {
$UserTwo = $User
}
$text = "Authentication success for Cred: $($UserOne) User: $($UserTwo) UserName: $($UserName)!"
$text | Out-File "C:\Temp\adlogin.txt"
}
}
Set-PSUAuthenticationMethod @Parameters
Product: PowerShell Universal
Version: latest version 4