Password during AD account creation

To meet the requirement of creating a password during the creation of an Active Directory (AD) account, we have implemented the following logic:

Example: $firstInitialLowercase@$lastInitialUppercase#$firstFourDigitOfFileNumber

However, in cases where the length of the first name is less than four digits, the AD creation process fails. We are seeking assistance in handling this situation. Can someone provide guidance on how to address this issue?

{
            "name": "password",
            "transform": {
                "type": "static",
                "attributes": {
                    "firstInitialLowercase": {
                        "type": "lower",
                        "attributes": {
                            "input": {
                                "type": "substring",
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "FIRST_NAME",
                                            "sourceName": "Application Name"
                                        }
                                    },
                                    "begin": 0,
                                    "end": 4
                                }
                            }
                        }
                    },
                    "lastInitialUppercase": {
                        "type": "upper",
                        "attributes": {
                            "input": {
                                "type": "substring",
                                "attributes": {
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "LAST_NAME",
                                            "sourceName": "Application Name"
                                        }
                                    },
                                    "begin": 0,
                                    "end": 4
                                }
                            }
                        }
                    },
                    "firstFourDigitOfFileNumber": {
                        "type": "substring",
                        "attributes": {
                            "input": {
                                "type": "accountAttribute",
                                "attributes": {
                                    "attributeName": "FILENUMBER",
                                    "sourceName": "Application Name"
                                }
                            },
                            "begin": 0,
                            "end": 4
                        }
                    },
                    "value": "$firstInitialLowercase@$lastInitialUppercase#$firstFourDigitOfFileNumber"
                }
            }

Hi @poison001,

I think its better to use Before and After Operation rule for this use case. Here’s the link for that:

Because in your use case, you will have to check the length of the first name and last name. It’s actually easy to accomplish that using PowerShell.

Hope this helps!

Did it work ? Should it be “begin”: 0,
“end”: 4 on all three of the attributes?

Hi @poison001,

the simple think is to pad your firstname at least 3 to 4 char before substring. And with that substring will give you always 4 chars at least. I will prepare an example for you now.

@poison001, here an example :

{
    "name": "password",
    "transform": {
        "type": "static",
        "attributes": {
            "firstInitialLowercase": {
                "type": "lower",
                "attributes": {
                    "input": {
                        "type": "substring",
                        "attributes": {
                            "input": {
                                "type": "rightPad",
                                "attributes": {
                                    "padding": "a",
                                    "length": "4",
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "FIRST_NAME",
                                            "sourceName": "Application Name"
                                        }
                                    }
                                }
                            },
                            "begin": 0,
                            "end": 4
                        }
                    }
                }
            },
            "lastInitialUppercase": {
                "type": "upper",
                "attributes": {
                    "input": {
                        "type": "substring",
                        "attributes": {
                            "input": {
                                "type": "accountAttribute",
                                "attributes": {
                                    "attributeName": "LAST_NAME",
                                    "sourceName": "Application Name"
                                }
                            },
                            "begin": 0,
                            "end": 4
                        }
                    }
                }
            },
            "firstFourDigitOfFileNumber": {
                "type": "substring",
                "attributes": {
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "FILENUMBER",
                            "sourceName": "Application Name"
                        }
                    },
                    "begin": 0,
                    "end": 4
                }
            },
            "value": "$firstInitialLowercase@$lastInitialUppercase#$firstFourDigitOfFileNumber"
        }
    }
}

Do the same think with lastInitialUppercase if needed.

Here i add “a”, on firstname if it’s length is less than for char. You have a choice, you can add “0” or another char for example and document this for your enduser.

No, It is not working

@poison001 i test this and it’s work.

{
    "name": "password",
    "transform": {
        "type": "static",
        "attributes": {
            "firstInitialLowercase": {
                "type": "lower",
                "attributes": {
                    "input": {
                        "type": "substring",
                        "attributes": {
                            "input": {
                                "type": "rightPad",
                                "attributes": {
                                    "padding": "a",
                                    "length": "4",
                                    "input": {
                                        "type": "accountAttribute",
                                        "attributes": {
                                            "attributeName": "FIRST_NAME",
                                            "sourceName": "Application Name"
                                        }
                                    }
                                }
                            },
                            "begin": 0,
                            "end": 4
                        }
                    }
                }
            },
            "lastInitialUppercase": {
                "type": "upper",
                "attributes": {
                    "input": {
                        "type": "substring",
                        "attributes": {
                            "input": {
                                "type": "accountAttribute",
                                "attributes": {
                                    "attributeName": "LAST_NAME",
                                    "sourceName": "Application Name"
                                }
                            },
                            "begin": 0,
                            "end": 4
                        }
                    }
                }
            },
            "firstFourDigitOfFileNumber": {
                "type": "substring",
                "attributes": {
                    "input": {
                        "type": "accountAttribute",
                        "attributes": {
                            "attributeName": "FILENUMBER",
                            "sourceName": "Application Name"
                        }
                    },
                    "begin": 0,
                    "end": 4
                }
            },
            "value": "$firstInitialLowercase@$lastInitialUppercase#$firstFourDigitOfFileNumber"
        }
    }
}

@baoussounda - Thank you very much, I really appreciate your Help. Yes, your code is working fine but I don’t want to use PAD transform anyway I used alternate solution to achieve this requirement.

1 Like

Do you mind sharing what your alternate solution was? Future readers of this topic may be interested in seeing how you did it.

@colin_mckibben - Requirement has been changed , I used static value on the basis combination of Identity attributes
I used FIRSTNAME+LASTNAME+HIREYEAR

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.