0 votes

Hey All,

My company is currently working on some automation between SAP Success Factors (HR Tool) and Adaxes.

We currently have it set so SAP generates a CSV export and Adaxes will pick it up and make adjustments to user accounts as needed.

The issue were running across is creation of usernames. SAP needs input from HR for whatever they want the username to be and does not recognize duplicates. Our idea is to somehow use Adaxes and have HR input a first and last name and have a unique username generated for them to input into SAP. Has anyone worked through this before or have any idea how to accomplish this if possible?

Thanks

by (520 points)
0

Hello!

If you are using Adaxes version 2018.2, a Custom Command with two Edit box parameters and a PowerShell script can be used. Users will need to enter First Name and Last Name and the script will generate the unique user name based on the values of the parameters and output the username into the execution log.
If you are using Adaxes version 2018.1 or earlier, the Modify User Web Interface action, a Business Rule and a PowerShell script can be used. The Web Interface action will use customized form with only two custom attributes (e.g. CustomAttributeText1 and CustomAttributeText2). The Business Rule triggering After Updating a User will execute the script that will generate a unique username based on the values of the modified properties and output the name into the execution log.
If the solution meets your needs, please, provide all the possible details regarding the username generation and we will provide you with the script and detailed instructions.

0

We're still on 2017.1 so the second option looks like it would work great.

We just need a standard, first letter of the first name and first seven of the last name. Any duplicates just increment a number at the end.

I appreciate the help!

Thanks

1 Answer

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

Hello,

Thank you for the provided details. To implement the solution:

i. Creating the Business Rule

  1. Launch Adaxes Administration Console.

  2. In the Console Tree, right-click your service node.

  3. In the context menu, navigate to New and click Business Rule.

  4. On step 2 of the Create Business Rule wizard, select User object type.

  5. Select After Updating a User and click Next.

  6. Click Add Action.

  7. Select Run a program or PowerShell script.

  8. Paste the below script into the Script field. In the script:

    • $firstNameProperty – Specifies the LDAP name of the custom attribute used to enter the first name (e.g. CustomAttributeText1);
    • $lastNameProperty – Specifies the LDAP name of the custom attribute used to enter the last name (e.g. CustomAttributeText2)
    • $usernameMaxLength – Specifies the maximum allowed number of characters in the sAMAccountName value (should not exceed 20).
     Import-Module Adaxes
    
     $firstNameProperty = "adm-CustomAttributeText1" # TODO: modify me
     $lastNameProperty = "adm-CustomAttributeText2" # TODO: modify me
    
     $usernameMaxLength = 20 # TODO: modify me
    
     function BuildUsername()
     {
         $samAccountNameBuilder = New-Object "System.Text.StringBuilder"
         for ($i=0; $i -lt $args.length; $i++)
         {
             if (-not($args[$i] -is [array]))
             {
                 if (-not([System.String]::IsNullOrEmpty($args[$i])))
                 {
                     [void]$samAccountNameBuilder.Append($args[$i].ToLower())
                 }
             }
             elseif ($args[$i].length -eq 3) 
             {
                 if (-not([System.String]::IsNullOrEmpty($args[$i][0])))
                 {
                     $valueLength = $args[$i][1]
                     if ($valueLength -gt $args[$i][0].Length)
                     {
                         $valueLength = $args[$i][0].Length
                     }
    
                     switch ($Args[$i][2])
                     {
                         "Beginning"
                         {
                             $value = $args[$i][0].SubString(0,$valueLength).ToLower()
                         }
                         "End"
                         {
                             $value = $args[$i][0].SubString($args[$i][0].Length - $valueLength).ToLower()
                         }
                     }
                     [void]$samAccountNameBuilder.Append($value)
                 }
             }
             else
             {
                 $Context.LogMessage("An error occurred while building a username!", "Error")
             }
         }
    
         return $samAccountNameBuilder.ToString()
     }
    
     function IsUsernameUnique($username)
     {
         $user = Get-AdmUser $username -erroraction silentlycontinue
         return $user -eq $Null
     }
    
     function GenerateUniqueUsername($username, $usernameMaxLength)
     {
         $uniqueUsername = $username
         for ($i = 1; $True; $i++)
         {
             if (IsUsernameUnique $uniqueUsername)
             {
                 # The username meets the requirements
                 return $uniqueUsername
             }
    
             $difference = $username.Length + $i.ToString().Length - $usernameMaxLength
             if ($difference -gt 0)
             {
                 $username = BuildUsername ($username, ($username.Length - $difference), "Beginning")
             }
             $uniqueUsername = BuildUsername $username $i.ToString()
         }
     }
    
     # Build the username
     $firstName = $Context.GetModifiedPropertyValue($firstNameProperty)
     $lastName = $Context.GetModifiedPropertyValue($lastNameProperty)
     if ([String]::IsNullOrEmpty($firstName) -or [String]::IsNullOrEmpty($lastName))
     {
         $Context.Cancel("First Name and Last Name must be specified for generating unique username.")
         return
     }
     $username = BuildUsername ($firstName, 1, "Beginning") "." ($lastName, 7, "Beginning")
    
     #Output unique username
     $uniqueUsername = GenerateUniqueUsername $username $usernameMaxLength
     $Context.LogMessage($uniqueUsername, "Information")
    
  9. Specify a description for the script.

  10. Click OK.

  11. Right-click the action you created and then click Add Condition.

  12. Select If <property> changed.

  13. Expand the dropdown list and select the Show all properties checkbox.

  14. Select the property used to specify the first name (e.g. CustomAttributeText1).

  15. Click OK.

  16. Repeat steps 11-15 for the custom attribute used to specify the last name.

  17. Click Next and finish creating the Business Rule. Finally, it should look like this:

ii. Creating the Web Interface action

  1. Launch Adaxes Web Interface Customization tool.
  2. Select the Web Interface you need.
  3. On the General tab, click Configure Home Page Actions.
  4. Click Add.
  5. Select Modify User and click Next.
  6. On step 3 of the Add Home Page Action wizard, select Always perform for the current user and click Next.
  7. Select Use customized form and click Customize Form.
  8. Delete all sections except for one (e.g. General).
  9. Delete all properties from the remaining section.
  10. Below Section fields, click Add.
  11. Select the Show all properties checkbox and select the property specified in the Business Rule condition.
  12. Click OK.
  13. Repeat steps 10-12 to add the second property.
  14. Click OK and finish creating the Home Page Action.

iii. Specifying a display name for custom attributes

  1. To change property display names, do the following on each computer where Adaxes components (Adaxes service, Web interface, Administration Console) are installed:

  2. Navigate to folder C:\ProgramData\Softerra\Adaxes 3\.

  3. Open the AttributeFriendlyNames2.eng.xml file (AttributeFriendlyNames2.deu.xml for German, AttributeFriendlyNames2.fra.xml for French) with a text editor.

  4. Add the friendlyNameItem XML element to the end of the file.

  5. Add the ldapName XML element and specify the property LDAP name in it.

  6. Add the friendlyName XML element and specify the property display name in it.

     <friendlyNames>
         ...
         <friendlyNameItem>
            <ldapName>adm-CustomAttributeText1</ldapName>
            <friendlyName>MyDisplayName</friendlyName>
         </friendlyNameItem>
     </friendlyNames>
  7. Repeat steps 3-6 for both custom text attributes you have added to the modify user form.

  8. Save the file.

  9. Restart Softerra Adaxes Service.

  10. Restart IIS.

  11. Restart Adaxes Administration Console.

0

This worked great, thanks a lot!

Related questions

0 votes
1 answer

Hello, We have customized the Web Interface, so the form for user creation has only First Name and Last Name fields. Username is generated automatically. But, when a user with ... the creator cannot change the username to fix it. How can I avoid this problem?

asked Jun 29, 2011 by jlkhj98 (150 points)
0 votes
1 answer

Trying to generate a custom report and getting an error when trying to add the resulting values back into the report columns - The part of code causing the issue is this - ... any way to run the $Context.Items.Add method to add multiple column values at once?

asked Sep 22, 2022 by sirslimjim (480 points)
0 votes
1 answer

Let me preface by saying that I am a Lotus Notes Developer that is very new to Adaxes and am learning as I go. I've created a form in Adaxes that has several fields ... and if so, can you point me to some examples? Your help will be greatly appreciated.

asked Mar 18, 2015 by sandramnc (870 points)
0 votes
1 answer

Hello, I would like to ensure that before a computer object is moved in Adaxes, the user must enter a ticket number, and after the input, the PC is moved to ... prompts the user to enter a ticket number before the move/delete operation? Kind regards, Fabian

asked Mar 20 by fabian.p (150 points)
0 votes
1 answer

Hello, Is it possible to execute a custom command after creating a user, with the intention to prompt the end user for more information? For example we have a User ... would then prompt for a 'Country' to be specified from a param dropdown list. Thanks

asked Mar 10, 2022 by bavery (250 points)
3,346 questions
3,047 answers
7,782 comments
544,981 users