Add Remote Session Credential Permission ​
POST /winapi/rscredentialpermissions
When applying permissions to a Remote Session Credential, the recipient does not need specific access to the linked password record at all.
The user executing the API script must be given access to the following:
- On the screen Administration -> Feature Access -> Hosts tab : 'Specify which users are allowed to have access to the main Hosts Menu'
- On the screen Administration -> Feature Access -> Remote Sessions tab : 'Specify which users are allowed to manage permissions on any Remote Session Credentials they have access to'
- The user must already have permissions to the Remote Session Credential for their account as well
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/winapi'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateURL'/rscredentialpermissions' -ContentType "application/json" -Body $jsonData -UseDefaultCredentials
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/winapi'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateURL'/rscredentialpermissions' -ContentType "application/json" -Body $jsonData -UseDefaultCredentials
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. |
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":""
}
]