Add Remote Session Credential Permission ​
POST /api/rscredentialpermissions
To add permissions to a Remote Session Credential record, you use the Remote Session Credentials API Key. When applying permissions to a Remote Session Credential, the recipient does not need specific access to the linked password record at all.
Adding permissions can be achieved as per the example below, using the following parameter descriptions:
Powershell
#Add permissions with no expiry date
$Body = @{
CredentialID = "1011"
ApplyPermissionsForUserID = "domain\username"
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateURL = 'https://passwordstate/api'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateURL'/rscredentialpermissions' -ContentType "application/json" -Body $jsonData -Header @{ "APIKey" = "<apikey>" }
Write-Output $resultPowershell
#Add permissions with expiry date
#Grant Access for 7 Days
$AccessExpiresAt = Get-Date
$AccessExpiresAt.AddDays(7) | Out-Null
$Body = @{
CredentialID = "1011"
ApplyPermissionsForUserID = "domain\username"
AccessExpiresAt = $AccessExipresAt
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateURL = 'https://passwordstate/api'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateURL'/rscredentialpermissions' -ContentType "application/json" -Body $jsonData -Header @{ "APIKey" = "<apikey>" }
Write-Output $result| Heading | Data Type | Description |
|---|---|---|
| CredentialID | Integer | Unique identifier for the Remote Session Credential record. Created automatically at the time the Remote Session Credential was added. |
| ApplyPermissionsForUserID | String (100) | The UserID you wish to apply permissions for |
| ApplyPermissionsForSecurityGroupID | Integer | The SecurityGroupID you wish to apply permissions for. You can only specify SecurityGroupID or SecurityGroupName, not both in the same call. |
| ApplyPermissionsForSecurityGroupName | String (NA) | The Security Group Name you wish to apply permissions for You can only specify SecurityGroupID or SecurityGroupName, not both in the same call. |
| AccessExpiresAt | (DataTime) | When applying permissions to a Remote Session Credential, you can have the permissions automatically removed by specifying a value for the AccessExpiresAt field. This field is to be specified in Universal Time format i.e. yyyy-mm-dd hh:ss, and the time is specified in 24 hour format. |
| APIKey | String (NA) | Remote Session Credential Key. This can either be specified in the HTTP Header, or within the POST Body |
Special Note: If you specify the value of 0 for ApplyPermissionsForUserID and ApplyPermissionsForSecurityGroupID, then All Users and Security Groups will be granted access. Equivalent to "All Users and Security Groups" you see in the UI.
Json
# Response
HTTP/1.1 200
[
{
"CredentialID":"1011",
"ApplyPermissionsForUserID":"domain\\username",
"ApplyPermissionsForSecurityGroupID":"",
"ApplyPermissionsForSecurityGroupName":"",
"AccessExiresAt":"",
"APIKey":"Redacted"
}
]