IAdmConfigObjectJson
The IAdmConfigObjectJson interface provides methods for converting Adaxes configuration objects to/from JSON.
Methods
-
Method
-
Description
-
ToJson()
-
Converts the configuration object to JSON.
-
FromJson()
-
Modifies the configuration object according to the provided JSON.
Details
ToJson()
Converts the configuration object to JSON.
string ToJson(string paramsJson)
Parameters
- paramsJson - specifies the JSON conversion parameters. The parameter usage depends on the context i.e. the configuration object you are calling this method for. Typically, the parameter can be set to
null
to simply convert the entire configuration object to JSON.
Examples
The following code sample obtains the REST API configuration and converts the brute force protection section of the configuration to JSON.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Prompt for credentials.
$credential = Get-Credential
# Bind to the REST API configuration container.
$containerPath = $service.Backend.GetConfigurationContainerPath("ClientAppsContainer")
$container = $service.OpenObject($containerPath, $credential.UserName, `
$credential.GetNetworkCredential().Password, 0)
$restApi = $container.RestApi
# Convert to JSON
$bruteForceConfig = $restApi.ToJson("{elements: ['BruteForceProtection']}")
FromJson()
Modifies the configuration object according to the provided JSON.
void FromJson(string paramsJson, string dataJson)
Parameters
- paramsJson - specifies the JSON conversion parameters. The parameter usage depends on the context i.e. the configuration object you are calling this method for. Typically, the parameter can be set to
null
to configure the entire object according to the JSON data. - dataJson - specifies a JSON object that represents the corresponding Adaxes configuration object.
Examples
The following code sample configures the REST API brute force protection settings according to the provided JSON.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service.
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Prompt for credentials.
$credential = Get-Credential
# Bind to the REST API configuration container.
$containerPath = $service.Backend.GetConfigurationContainerPath("ClientAppsContainer")
$container = $service.OpenObject($containerPath, $credential.UserName, `
$credential.GetNetworkCredential().Password, 0)
$restApi = $container.RestApi
# Configure brute force protection settings.
$bruteForceConfig = @"
{
"type": 1,
"bruteForceProtection": {
"enabled": true,
"captchaEnabled": false,
"captchaAttemptsCount": 0,
"delayResponseEnabled": true,
"delayResponseAttemptsCount": 3,
"securityQuestionEnabled": false,
"securityQuestionAttemptsCount": 0,
"showGenericErrorMessageEnabled": true,
"invalidLoginWarningLimit": 10000,
"captchaSettings": {
"captchaWidth": 310,
"captchaHeight": 70,
"captchaLength": 6,
"backgroundColor": 16777215,
"charSet": "abcdefghkmnpqrstuvwxyz23456789",
"fontDistortionLevel": 0,
"fontFamilyName": "Times New Roman",
"fontStyle": 0,
"fontColor": 6908265,
"minFontSize": 30,
"maxFontSize": 50,
"noiseLevel": 0,
"noiseColor": 15527666,
"noiseLinesCount": 5,
"noiseLinesColor": 6908265,
"verticalWaveAmplitude": 10,
"horizontalWaveAmplitude": 5
}
}
}
"@
$restApi.FromJson("{elements: ['BruteForceProtection']}", $bruteForceConfig)
Requirements
Minimum required version: 2023