Adding a New Password List ​
POST /winapi/passwordlists
Adding a new Password List object can be achieved by making a POST request on the URL, with appropriate fields forming the HTTP message body. To create Password Lists, you must have access to the 'Add Shared Password List' and/or 'Add Private Password List' menus within the Passwordstate UI.
This method returns the new Password List object as described above.
The following example shows, in PowerShell, how to create a new Folder, and then a new Password List, and nest the new Password List beneath the new Folder.
Powershell
# Powershell Request (POST)
#JSON data for the object
$Body = @{
FolderName = "Test Folder"
Description = "First API Folder"
CopyPermissionsFromPasswordListID = $PasswordListID
CopyPermissionsFromTemplateID = ""
NestUnderFolderID = "0"
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateUrl = 'https://passwordstate/winapi/folders'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials
$FolderID = $result.FolderID
#JSON data for the object
$Body = @{
PasswordList = "Windows S2012"
Description = "Windows Servers 2012"
CopySettingsFromPasswordListID = $PasswordListID
CopySettingsFromTemplateID = ""
LinkToTemplate = "False"
CopyPermissionsFromPasswordListID = $PasswordListID
CopyPermissionsFromTemplateID = ""
NestUnderFolderID = $FolderID
SiteID = "0"
}
$jsonData = $Body | ConvertTo-Json
$PasswordstateUrl = 'https://passwordstate/winapi/passwordlists'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials
$PasswordListID = $result.PasswordListIDJson
# Response
HTTP/1.1 200
[
"PasswordListID": 27,
"PasswordList": "Web Site's",
"Description": "Various web sites on the net",
"ImageFileName": "website.png",
"Guide": "",
"AllowExport": true,
"PrivatePasswordList": false,
"TimeBasedAccessRequired": false,
"NoApprovers": "1",
"DisableNotifications": false,
"PasswordStrengthPolicyID": 7,
"PasswordGeneratorID": 1,
"CodePage": "Unicode (UTF-8)",
"PreventPasswordReuse": 5,
"AuthenticationType": "None Required",
"AuthenticationPerSession": false,
"PreventExpiryDateModification": false,
"SetExpiryDate": 0,
"ResetExpiryDate": 0,
"PreventDragDrop": true,
"PreventBadPasswordUse": true,
"ProvideAccessReason": true,
"TreePath": "\ISP Accounts",
"TotalPasswords": 23,
"GeneratorName": "Default Password Generator",
"PolicyName": "SQL Server Policy",
"PasswordResetEnabled": false,
"ForcePasswordGenerator": false,
"HidePasswords": "false:false:false",
"ShowGuide": false,
"EnablePasswordResetSchedule": false,
"PasswordResetSchedule": "05:30",
"AddToExpiryDate": 120,
"AddToExpiryDateInterval": "Days",
"OneTimePasswords": false,
}
]Powershell
# Powershell Request (POST)
#To add a Private Password List for a user
#JSON data for the object
$jsonData = '
{
"PasswordList":"John Melvin's Private List",
"Description":"Personal Passwords",
"ApplyPermissionsForUserID":"domain\\jmelv",
"Permission":"A",
"PrivatePasswordList":"True",
"NestUnderFolderID":"0"
}
'
$PasswordstateUrl = 'https://passwordstate/winapi/passwordlists'
$result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials
$PasswordListID = $result.PasswordListIDWhen creating a new Password List, there are a few options for copying settings and permissions from other Password Lists or Templates, where to place the Password List in the Navigation Tree, and if you want to link the Password List to a Template:
| Heading | Data Type | Description |
|---|---|---|
| CopySettingsFromPasswordListID | String | To copy settings and field configurations to the Password List from an existing Password List, you can specify the PasswordListID value for this field |
| CopySettingsFromTemplateID | String | To copy settings and field configurations to the Password List from an existing Password Template, you can specify the TemplateID value for this field |
| LinkToTemplate | Boolean | If you want to Link the new Password List to an existing Password List Template, then you can specify the values of true or false here. Note: When doing this, you must also specify a value for the field CopySettingsFromTemplateID, and not use the field CopySettingsFromPasswordListID |
| CopyPermissionsFromPasswordListID | String | To copy permissions to the Password List from an existing Password List, you can specify the PasswordListID value for this field |
| CopyPermissionsFromTemplateID | String | To copy permissions to the Password List from an existing Password List Template, you can specify the TemplateID value for this field |
| NestUnderFolderID | String | If you would like this newly created Password List to be nested beneath another Folder or Password List, specify the FolderID or PasswordList value here. If omitted, the Password List will be created in the root of the Navigation Tree - which is equivalent to the value of 0. Note: If you are nested this Password List beneath a Folder structure which is propagating its permissions down, then you cannot use any of the CopyPermissionsFrom properties. |
| PrivatePasswordList | String | To create either a Shared or Private Password List - specify True or False. Note: When creating a Private Password List for a user, you cannot copy permissions from other Password List or Template, or apply permissions based on a Security Group. |
| ApplyPermissionsForUserID | String | Specified which User will be given permission to this newly created Password List. |
| ApplyPermissionsForSecurityGroupID | String | Specified which Security Group, by ID, which will be given permission to this newly created Password List. You cannot apply permissions for a Security Group by ID and Name during the same API call. |
| ApplyPermissionsForSecurityGroupName | String | Specified which Security Group, by Name, which will be given permission to this newly created Password List. You cannot apply permissions for a Security Group by ID and Name during the same API call. |
| Permission | String | When apply permissions to the newly created Password List (for a User or Security Group), you must specify the values of A, M or V - Administrator, Modify or View rights. |
| ImageFileName | String (50) | An image file name associated with the Password List - as can be seen on the screen Administration -> Passwordstate Administration -> Images and Account Types. |
| Guide | String (NA) | Specify a guide for the intended use of the Password List. |
| SiteID | Integer | By default, the Site Location of 'Internal' will be used if an alternate Site Location is not used. Note: SiteID's can be referenced on the screen Administration -> Remote Site Administration -> Remote Site Locations. For the site of "Internal", the SiteID = 0. |