Add safe Member, Permissions value is invalid

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add safe Member, Permissions value is invalid

L3 Networker

Hi all,

 

Currently, I can't get adding a safe member to work correctly:

Invoke-RestMethod -Uri "https://XXXXXXXXX/PasswordVault/WebServices/PIMServices.svc/Safes/$IA_safename/Members" -Method Post -Body $addVaultAdmins -Headers $Headers -ContentType 'application/json'

is fed with this json:

{ "member": { "MemberName": "Vault Admins", "SearchIn": "Vault", "MembershipExpirationDate": "", "Permissions": [ { "Key": "UseAccounts", "Value": true }, { "Key": "RetrieveAccounts", "Value": true }, { "Key": "ListAccounts", "Value": true }, { "Key": "AddAccounts", "Value": true }, { "Key": "UpdateAccountContent", "Value": true }, { "Key": "UpdateAccountProperties", "Value": true }, { "Key": "InitiateCPMAccountManagementOperations", "Value": true }, { "Key": "SpecifyNextAccountContent", "Value": true }, { "Key": "RenameAccounts", "Value": true }, { "Key": "DeleteAccounts", "Value": true }, { "Key": "UnlockAccounts", "Value": true }, { "Key": "ManageSafe", "Value": true }, { "Key": "ManageSafeMembers", "Value": true }, { "Key": "BackupSafe", "Value": true }, { "Key": "ViewAuditLog", "Value": true }, { "Key": "ViewSafeMembers", "Value": true }, { "Key": "RequestAuthorizationLevel", "Value": 2 }, { "Key": "AccessWithoutConfirmation", "Value": true }, { "Key": "CreateFolders", "Value": true }, { "Key": "DeleteFolders", "Value": true }, { "Key": "MoveAccountsAndFolders", "Value": true } ] } }

This results in this error:

Invoke-RestMethod : {"ErrorCode":"CAWS00001E","ErrorMessage":"Failed to add User or Group Vault Admins. Reason: Input parameter for [Permissions] value is invalid."} At file.ps1:169 char:20 + ... DB_reply = Invoke-RestMethod -Uri "https://xxxxxx/PasswordVault/WebServ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Does anyone spot the mistake that leads to "Reason: Input parameter for [Permissions] value is invalid."

 

 

Thanks & Regards,

Mat

1 accepted solution

Accepted Solutions

There are only the standard PVWA & IIS logs.

I think I remember experiencing this issue when developing the psPAS module, but do not recall the specific resolution.

You could try to break the request down into smaller chunks to try and isolate which part of the JSON is causing issues - i.e. can all of the permissions be set individually? in groups of 2, 3, 4 etc - it might help you find the permission the API is complaining about.

View solution in original post

9 REPLIES 9

L7 Applicator

Try to specify the permissions value als True (capital T) instead of true.

L2 Linker

The body looks good. I had no issues while testing it with postman. But, i see that you're doing via PS, did you try giving the {"Key":"IPAddress", "Value": "ip"} ? It works sometimes.

L7 Applicator

Another thought: When you manually log in to the PVWA with the user that you use in your PS script, can you add the same permissions there? Remember... you cannot assign permissions on a safe that you yourself don't have on that safe.

​Just tried that, didn't work unfortunately....

​You mean by not breaking the line after the key definition? I use $var{ _json_data_} | ConvertTo-Json -Depth 3 and it automatically results in that format. I also tried using -Compress, same result.

L3 Networker

​It is a newly created safe from the same user I use to add this user group. All permission ticks are set, manually it just works fine.

L3 Networker

Is there a good log to analyze for API errors?

There are only the standard PVWA & IIS logs.

I think I remember experiencing this issue when developing the psPAS module, but do not recall the specific resolution.

You could try to break the request down into smaller chunks to try and isolate which part of the JSON is causing issues - i.e. can all of the permissions be set individually? in groups of 2, 3, 4 etc - it might help you find the permission the API is complaining about.

solved by by your approach, typo here:

changed

{ "Key": "RequestAuthorizationLevel", "Value": 2 },

to

 

{ "Key": "RequestsAuthorizationLevel", "Value": 2 },

 

  • 1 accepted solution
  • 1050 Views
  • 9 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!