Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception calling "SecureStringToBSTR" with "1" argument(s): "Value cannot be null #56

Closed
clyates4 opened this issue May 20, 2022 · 4 comments

Comments

@clyates4
Copy link

Each time a command is executed, the following error is displayed before the command runs:

Exception calling "SecureStringToBSTR" with "1" argument(s): "Value cannot be null.
Parameter name: s"
At C:\Users\cyates\OneDrive - Company
Energy\Documents\WindowsPowerShell\Modules\SailPointIdentityNow\1.1.5\scripts\Get-IdentityNowAuth.ps1:167 char:5

  • $clientSecretv3 = [System.Runtime.InteropServices.marshal]::PtrTo ...
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : ArgumentNullException

Here is the code referenced in the error:

Generate the account hash

$hashUser = Get-HashString $adminUSR.ToLower() 
$adminPWD = Get-HashString "$($adminPWDClear)$($hashUser)"  

$clientSecretv3 = [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($IdentityNowConfiguration.v3.Password))

Here is the org configuration

$orgName = "our-org"
Set-IdentityNowOrg -orgName $orgName

# IdentityNow Admin User
$adminUSR = "identityNow_admin_User"
$adminPWD = 'idnAdminUserPassword'
$adminCreds = [pscredential]::new($adminUSR, ($adminPWD | ConvertTo-SecureString -AsPlainText -Force))

# IdentityNow Personal Access Token as generated through the IdentityNow Portal and your personal identity profile preferences
$patClientID = 'd3d1f84bb7112212b26e59cd02242a50'
$patClientSecret = '60132a77b0b64959dbcea23ace211f3afb4f11ab8aae92fe4fcdabe0a8379a88'
$patCreds = [pscredential]::new("$($patClientID)", ($patClientSecret | ConvertTo-SecureString -AsPlainText -Force))

Set-IdentityNowCredential -AdminCredential $adminCreds -PersonalAccessToken $patCreds
Save-IdentityNowConfiguration
@darrenjrobinson
Copy link
Owner

I've gone through and setup a new machine with the module using PowerShell 5.1.
I then tested the creds using Test-IdentityNowCredentials
I only set it up using a personal access token (v3 creds) so the v2 creds did fail as expected.

    $orgName = "myOrg"
    Set-IdentityNowOrg -orgName $orgName

    # IdentityNow Admin User
    $adminUSR = "identityNow_admin_User"
    $adminPWD = "idnAdminUserPassword"
    $adminCreds = [pscredential]::new($adminUSR, ($adminPWD | ConvertTo-SecureString -AsPlainText -Force))

    # IdentityNow Personal Access Token as generated through the IdentityNow Portal and your personal identity profile preferences
    $patClientID = "yourClientID"
    $patClientSecret = "yourClientSecret"
    $patCreds = [pscredential]::new("$($patClientID)", ($patClientSecret | ConvertTo-SecureString -AsPlainText -Force))

    Set-IdentityNowCredential -AdminCredential $adminCreds -PersonalAccessToken $patCreds
    Test-IdentityNowCredentials 

image

I can't reproduce your error.
Can you test/validate your credentials using Test-IdentityNowCredentials

@clyates4
Copy link
Author

clyates4 commented Oct 11, 2022 via email

@darrenjrobinson
Copy link
Owner

Hi @clyates4
v1.1.6 of the module addresses this error.
It is currently in this branch which you can download an manually update your environment with. https://github.com/darrenjrobinson/powershell_module_identitynow/tree/V3API-CMDLET-Options

It also includes a number of other enhancements for changes to the IDN APIs.
I'll be looking to finalise that version in the next week, merge it with Main and publish v.1.1.6 to the PowerShell Gallery.

@clyates4
Copy link
Author

clyates4 commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants