0 votes

We have a property pattern for a user's job title that lists all the aviable titles. I need to be able to add a new constraint to this within a custom command and from Powershell on a differant computer.

Would you be able to help?

by (1.3k points)
0

Hello,

Do we understand correctly that you want to add new values to the list of allowed for the Job Title property via Windows PowerShell on a computer where Adaxes service does not run or via a Custom Command? If so, a script will be used in both cases. To perform the update via Windows PowerShell, Adaxes ADSI Provider needs to be installed on the computer. For information on how to install the provider, please, have a look at the following SDK article: http://adaxes.com/sdk/HowDoI.InstallAdsiProvider. The Custom Command will use a text parameter to specify the value to be added.

If this is not what you need, please, describe the desired behavior in all the possible details with live examples.

0

Yes that is correct. We already have Adaxes ADSI Provider installed on the other computer.

1 Answer

0 votes
by (216k points)

Hello,

Thank you for the confirmation. To add values via a Custom Command, you can use the following script from our repository: https://www.adaxes.com/script-repository/add-new-allowed-property-value-to-a-property-pattern-s585.htm.

To add values via Windows PowerShell, you can use the script below:

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$propertyName = "title" # TODO: modify me
$propertyPatternDN = "CN=My Pattern,CN=Property Patterns,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me

# Get value
$value = Read-Host "Specify the value to add"

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

# Bind to the Property Pattern
$userPattern = $admService.OpenObject("Adaxes://$propertyPatternDN", $NULL, $NULL, 0)

$values = New-Object System.Collections.ArrayList
$isPropertyRequired = $False
foreach ($item in $userPattern.Items)
{
    if ($item.PropertyName -ne $propertyName)
    {
        continue
    }

    $constraints =  $item.GetConstraints()
    $constraint = $constraints.GetConstraint("ADM_PROPERTYCONSTRAINTCATEGORY_VALUEFORMAT")

    # Check if new value exists
    if ($constraint.Values -contains $value)
    {
        return
    }

    # Get current values
    $constraint.Values | %{[void]$values.Add($_)}
    $isPropertyRequired = $item.IsPropertyRequired

    # Remove Property Pattern item
    $userPattern.Items.Remove($item)
    break
}

# Add new value
[void]$values.Add($value)

# Sort values
$values.Sort()

# Update Property Pattern
$item = $userPattern.Items.Create()
$item.PropertyName = $propertyName
$item.IsPropertyRequired = $isPropertyRequired

$constraints = $item.GetConstraints()
$constraint = $constraints.Create("ADM_PROPERTYCONSTRAINTTYPE_VALUERANGE")
$constraint.AreValuesDenied = $False
$constraint.Values = $values.ToArray()
$constraints.Add($constraint)
$item.SetConstraints($constraints)

# Save the changes
$item.SetInfo()
$userPattern.Items.Add($item)

In the script:

  • $propertyName – Specifies the LDAP name of the property for which a new value will be added.
  • $propertyPatternDN – Specifies the distinguished name (DN) of the Property Pattern to be updated. For information on how to get the DN of a directory object, see Get the DN of an Active Directory object.

When prompted, enter the value to be added to the list of allowed ones.

0

When trying to add this script into adaxes 12.1 updated, I get an error for the % Operator.

"Invalid Expression" "The generating expression contains invalid characters2022-08-19_17h14_48.png"

0

Hello,

This behaviour is by design. The thing is that is Adaxes the percent (%) character is considered to be the beginning or the end of a value reference. As it is mentioned in the answer above, that version of script should be executed in Windows PowerShell, not in Adaxes. If you want to execute the script in Adaxes (e.g. in a custom command), use this script from our repository: https://www.adaxes.com/script-repository/add-new-allowed-property-value-to-a-property-pattern-s585.htm.

Related questions

0 votes
1 answer

Good afternoon, I'm looking to generate a script to allow automation of updating job titles using a spreadsheet. To do this we would use a spreadsheet generated by ... in calling the file. Please let me know if you require any additional information Regards

asked Nov 16, 2020 by jtop (700 points)
0 votes
0 answers

WorkFlow : From Adaxes, how can the Director or Assistant validate the employee’s "Job Title" modification request?

asked Jul 12, 2023 by LucasGrd (40 points)
0 votes
0 answers

From Adaxes, how can the Director or Assistant validate the employee’s "Job Title" modification request ?

asked Jun 15, 2023 by LucasGrd (40 points)
0 votes
1 answer

Is there a report that I can run that shows everyone with a specific job title

asked Apr 20, 2023 by sra98a (120 points)
0 votes
1 answer

I am searching for a good workflow for changing the manager field of users when there is a change in management. I was thinking of doing it based off job title. So I was ... of job titles so that would be ideal. Thanks for the help and the awesome product.

asked Oct 1, 2022 by Dynamic6553 (20 points)
3,548 questions
3,238 answers
8,232 comments
547,811 users