0 votes

Is it possible to trim the values before saving the values? e.g., when someone copies and pastes a first name, it has a trailing space and this is carried over to AD too. Is it possible to trim this value?

by (730 points)

1 Answer

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

Hello,

Yes, sure. You can do this with the help of a PowerShell script. For example, the following script trims leading and trailing whitespace from the First Name and Last Name properties:

$props = @("givenName", "sn") # TODO: Modify me

foreach ($prop in $props)
{
    if ($Context.IsPropertyModified($prop))
    {
        try
        {
            $value = ($Context.GetModifiedPropertyValue($prop)).Trim()
        }
        catch
        {
            continue
        }
        $Context.SetModifiedPropertyValue($prop, $value)
        $Context.LogMessage($prop + ": " + $value, "Information")
    }
}

In the script, $props specifies the properties, values of which need to be trimmed. If necessary add other properties you need.

To use the script with Adaxes, you need to create a Business Rule triggered before an operation is complete:

  • before creating a user: to trim properties on user creation,
  • before updating a user: to trim properties when a user account is modified.

To launch the script in a Business Rule, you need to use the Run a program or PowerShell script action.

To create such Business Rules:

  1. Create a new Business Rule.

  2. On the 2nd step of the Create Business Rule wizard, select User and Before Creating a User for a Business Rule launched when creating a user:

    **- or -**

    select User and Before Updating a User for a Business Rule launched when updating a user account:

  3. On the 3rd step, add the Run a program or PowerShell script action and paste the above script in the Script field.

0
0

OK thanks, got it

Related questions

0 votes
0 answers

Hello, as you can see in the attached picture some of the words are in English and some in German. As I can oversee it's the only page with that behaviour - all other pages are in English. Regards.

asked Jan 2, 2018 by HorstR (460 points)
0 votes
1 answer

Hello, Is it possible to configure Adaxes WEB field so it would show not the actual values but translated ones? What I am looking for is to show AD atribute ms-Exch-Recipient ... we could show the display type of the value, that would be much better. Thanks.

asked Dec 12, 2017 by DLe (760 points)
0 votes
1 answer

I read the article on using a business rule to automatically set certain field values such as address based on the value of the Office field. Is there any way to do ... on the Office field so the user has immediate feedback and can change it if necessary.

asked Aug 15, 2016 by jscovill (110 points)
0 votes
1 answer

I'm testing making changes to a mailbox that is synced between AD and Office365. During changes updates are not reflected back. I'm prompted that the replication with AD Connect has ... in the web interface. If I go to the console I can see the change.

asked Aug 6, 2020 by ComputerHabit (790 points)
0 votes
0 answers

We're having an issue where removing groups from a user object gets executed in AD and also reflected if browsing through the Adaxes Admin Console to the user object, but ... cache, but that didn't make a difference. Does anybody experience this issue, too?

asked Dec 12, 2016 by rsc (40 points)
3,548 questions
3,238 answers
8,232 comments
547,810 users