0 votes

I would like to add a parameter for country to a custom command. Since the country has to be entered correctly in order for Active Directory to accept it, I would like to use a drop down to ensure it is all formatted and spelled correctly. There are 200+ countries to fill out so if I can do it with a script it will be a lot easier. Is there a way to populate the drop down list using the sdk? I didn't find it in the documentation and the sample scripts didn't use parameters.

by (4.3k points)
0

Hello Mark,

Yes, it is possible. For us to provide you with the script. Please, specify from where it should take the list of countries. Should the list be predefined in the script itself?

0

Awesome. I got a list from Microsoft Windows.

$country = [CultureInfo]::GetCultures([System.Globalization.CultureTypes]::SpecificCultures) | ForEach-Object {(New-Object System.Globalization.RegionInfo $_.Name).EnglishName} | Select-Object -Unique | Sort-Object
0

Hello Mark,

Could you, please, also specify whether the Custom Command already has parameters or the new parameter will be the only one?

0

It has parameters already. This will be added to it.

1 Answer

0 votes
by (184k points)
selected by
Best answer

Hello Mark,

Thank you for specifying. Below is the script that will do the trick. Execute the script in Windows PowerShell on the computer where Adaxes service is installed. When prompted, enter the credentials of the Adaxes service account (specified during Adaxes installation). In the script:

  • $parameterName - Specifies the name of the parameter that will be created. Make sure it does not match a name of any existing parameters in the Custom Command.
  • $commandDN - Specifies the distinguished name (DN) of the Custom Command to which the parameter will be added. For information on how to get the DN, have a look at the following SDK article: https://adaxes.com/sdk/HowDoI.GetDnOfObject.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

$parameterName = "Country" # TODO: modify me
$commandDN = "CN=My Command,CN=Custom Commands,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me

# Get the list of countries
$countries = [CultureInfo]::GetCultures([System.Globalization.CultureTypes]::SpecificCultures) | ForEach-Object {(New-Object System.Globalization.RegionInfo $_.Name).EnglishName} | Select-Object -Unique | Sort-Object

# Prompt for credentials
$credential = Get-Credential

# Bind to the Custom Command
$command = $admService.OpenObject("Adaxes://$commandDN", $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Create new parameter
$parameter = $command.CreateParameter("ADM_PARAMETERTYPE_LIST")
$parameter.Name = $parameterName

# Add parameter values
$arrayList = New-Object "System.Collections.ArrayList"
foreach ($country in $countries)
{
    $predefinedValue = $parameter.CreateValue()
    $predefinedValue.Value = $country
    [void]$arrayList.Add($predefinedValue)
}
$parameter.Values = $arrayList.ToArray()

# Update Custom Command
$parametersArray = $command.Parameters
$parametersArray += $parameter
$command.Parameters = $parametersArray
$command.SetInfo()
0

Thank you!

Related questions

0 votes
1 answer

I have an ADP Sync scheduled task that modifies and creates users from a csv file. I also have reports that show new users created and management history for user ... ADP Sync scheduled task so that they only run after the ADP Sync task is complete?

asked Jan 7 by barberk (290 points)
0 votes
1 answer

I need a list of all the URLs that Adaxes creates in IIS on the server Adaxes is installed on.

asked Feb 6 by DaralenManta (250 points)
0 votes
1 answer

I am trying to see if I can implement this in Adaxes somehow to support role-based provisioning to external apps (using appropriate Powershell scripts) but struggling to work ... to invest in a full-blown role-based provisioning platform (would rather not!).

asked Dec 24, 2019 by Bernie (1.8k points)
0 votes
1 answer

Adaxes version is 2018.2. I have build a custom report, and I don't want the 'Name' column with the pictures to appear in it. But it seem to be mandatory, it is greyed ... . Is there a way to remove / hide / or change the mandatory attribute or column ? Thanks

asked Jan 9 by Isabelle (280 points)
0 votes
1 answer

As the title says, Im looking to add a Custom Command to the Action pane that I plan to allow users to trigger a script to run. However when in the Web Config for ... as has the permissions to make changes to the Web Inferface. Am I missing something? Thanks

asked Jul 16, 2019 by Helios5287 (510 points)
2,287 questions
2,042 answers
5,580 comments
52,796 users