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 params)
Parameters
- params – the JSON conversion parameters. The parameter usage depends on the configuration object for which this method is called. Typically, the parameter can be set to
nullto 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 params, string data)
Parameters
- params – the JSON conversion parameters. The parameter usage depends on the configuration object for which this method is called. Typically, the parameter can be set to
nullto configure the entire object according to the JSON data. - data – 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($null, $bruteForceConfig)
The following code sample sets the script execution timeout to 15 minutes.
[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 'Configuration Set Settings' container.
$path = $service.Backend.GetConfigurationContainerPath("ConfigurationSetSettings")
$settings = $service.OpenObject($path, $credential.UserName,`
$credential.GetNetworkCredential().Password, 0)
# Change parameter value.
$parameterValue = [Timespan]::FromMinutes(15).TotalMilliseconds
$settings.FromJson("Adsi.ScriptExecutionTimeout", ($parameterValue | ConvertTo-Json))
Requirements
Minimum required version: 2023