Searching for Passwords ​
GET /userapi/searchpasswords
There are two ways in which you can search for Passwords via the API, and you can search just within a single Password List, or across all Shared Passwords Lists. The two search methods are:
- Via a General Search across the majority of fields in the Passwords table
- Via Specific Search criteria, based on fields and values you specify in the URL
Note 1: You can perform an exact match search by enclosing your search criteria in double quotes i.e. "root_admin".
Note 2: By default, the retrieval of all Password records will add one Audit record for every Password record returned. If you wish to prevent audit records from being added, you can set the PreventAuditing parameter to true - if this parameter is omitted, the default option is false.
Powershell
# General Search by Password List
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/<PasswordListID>?search=<value>&PreventAuditing=<value>'
# General Search across all Password Lists and all Fields
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/?search=<value>&PreventAuditing=<value>'
# Specific Search, by 'Title', within a Password List
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/<PasswordListID>?title=<value>&PreventAuditing=<value>'
# Specific Search, by 'UserName', within a Password List
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/<PasswordListID>?username=<value>&PreventAuditing=<value>'
# Specific Search, by 'Title' and 'UserName', across all Password Lists
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/?title=<value>&username=<value>&PreventAuditing=<value>'
# Search by SiteID
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/?SiteID=<value>'
# Search by Site Location
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/?SiteLocation=<value>'
# Search by UserName and Site Location
$PasswordstateUrl = 'https://passwordstate/userapi/searchpasswords/?username=<value>&SiteLocation=<value>'
Invoke-Restmethod -Method GET -Uri $PasswordstateUrl -Header @{ "UserID" = "<UserID>" ; "APIKey" = "<APIKey>" }'General Search' Instructions
When performing a General Search, it will query the Passwords table for fields which Contain the value you specify for the Search= parameter. The fields which will be searched are:
- Title
- ADDomainNetBIOS
- HostName
- UserName
- AccountType
- Description
- GenericField1
- GenericField2
- GenericField3
- GenericField4
- GenericField5
- GenericField6
- GenericField7
- GenericField8
- GenericField9
- GenericField10
- Notes
- URL
- SiteID
- SiteLocation
'Specific Search' Instructions
When performing a Specific Search, it will query the Passwords table based on one or more of the parameters you specify in the URL. The fields which can be searched are:
- Title
- HostName
- ADDomainNetBIOS
- UserName
- AccountTypeID
- AccountType
- Description
- GenericField1
- GenericField2
- GenericField3
- GenericField4
- GenericField5
- GenericField6
- GenericField7
- GenericField8
- GenericField9
- GenericField10
- Notes
- URL
- PasswordResetEnabled
- ExpiryDate
- ExpiryDateRange
- AndOr
ExpiryDate Searching Explained
When performing a Specific Search by the ExpiryDate field, it will perform an exact match on this value. If you wish to query based on a date range, then omit this parameter and use the ExpiryDateRange parameter instead.
Note: Dates must be supplied in the ISO 8601 international standard for date format of YYYY-MM-DD.
ExpiryDateRange Searching Explained
It is possible to specify SQL style query syntax for the ExpiryDateRange parameter, so you can construct a query based on date ranges if needed.
Examples of the query syntax you can use is (ensure you separate two dates with a single comma):
ExpiryDateRange=ExpiryDate>=2012-07-06,ExpiryDate<=2013-01-01
ExpiryDateRange=ExpiryDate>2012-01-01,ExpiryDate<=2012-02-28
ExpiryDateRange=ExpiryDate>2013-01-01
ExpiryDateRange=ExpiryDate<=2012-11-30
Note: Dates must be supplied in the ISO 8601 international standard for date format of YYYY-MM-DD.
AndOr Operator Explained
As you can build up your query string based on one or more fields, you can also specify how these queries are joined in the SQL query - either using the OR operator, or the AND operator. If you omit this parameter from the URL, AND will be used.
As you'd expect, using the OR operator will return a greater number of results, while the AND operator will return less results as it is a more specific type of query.
Two examples URLs to use are:
https://passwordstate/searchpasswords/<PasswordListID>?Username=<Username>&Title=<Title>&AndOr=Or
https://passwordstate/searchpasswords/<PasswordListID>?Username=<Username>&Title=<Title>&AndOr=And
Final Search Notes
As you are passing parameters via the URL, it's possible you may wish to query based on characters which normally form part of the normal Query String syntax. If this is the case, then you may want to URL Encode parts of your search criteria. An example of this would be:
The ampersand character of & - you would instead need to represent this as %26