This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Change initial value of CentralPassword during the creation of a Person

Hello,

In the project that I'm doing for a Customer the have a pattern to define the initial value of the password based on the FirstName, LastName and the date of the creation.

I'm modifying the CentralPassword Template to generate it but after the creation of the Person, the password is not configured correctly. Is not empty so probably is using a random password.

How could I modify that column so the first value is based in my code instead of in a random password?

The purpose if this is generate two different AD account in different domains but with the same password and, whenever a helpdesk person changes the centralpassword, replicates it to the domains.

Thx!

Parents
  • You may wanna share the code of your template to make it easier for the community members to help you out. Thank you.

  • Hello,

    Here is the code:

    If NOT $[IsLoaded]:Bool$ Then

        'Chequeamos que haya First Name y Last Name
        If String.IsNullOrEmpty($Firstname$) AndAlso String.IsNullOrEmpty($Lastname$) Then
            Dim today As Date = DateTime.now
            Dim Password As String = ""
            Password += $FirstName$.Substring(0,1)
            Password += "*"
            If today.Day.ToString().Length = 1 Then
                Password += "0" + today.Day.ToString()
            End If
            If today.Month.ToString().Length = 1 Then
                Password += "0" + today.Month.ToString()
            End If
            Password += "*"
            If $LastName$.Length > 2 then
                Password += $LastName$.Substring($LastName$.Length - 2)
            else
                Password += $LastName$
            end if
            Password = Password.ToLower
            Value = Password

            'Hardcoded Password

            'Value = "Abcd.1234!"


        end if

    End If

  • Okay. Now please share

    • What version are you using?
    • Is your database encrypted?
    • The column you have placed the template on is Person.CentralPassword I assume?
  • Your code is only executed if FirstName is empty etc ....... I assume you meant NOT empty?

     If String.IsNullOrEmpty($Firstname$) AndAlso String.IsNullOrEmpty($Lastname$) Then

  • Hello,

    Version 8.0.1

    not encrypted

    Person.CentralPassword

  • Yes, you are right:

    If not String.IsNullOrEmpty($Firstname$) AndAlso not String.IsNullOrEmpty($Lastname$) Then

    I want to set the password when I save the Person the first time and I have the FirstName and LastName

  • Is the configuration parameter QER\Person\UseCentralPassword\PermanentStore enabled?

  • Hello,

    Yes, it's enabled. I'm checking the answer from Barry because the if not string..... could not be compiled in the database. I'm going to check it now.

  • Barry was right. I modified the condition but not compiled. Now, If I hardcode the password Abcd.1234! is assigned correctly. Unfortunately, my code doesn't generate a good password. As soon as I move from the lastname to another field, I get this error:

    [810359] The value in column CentralPassword did not match the password policy restrictions  Employee central password policy.

    This is one example: a*2006*ia

    I have modified the policy for employees to not require an upper case character.

  • If you want to move the password policy check to the save operation you need to implement your password generation code in the OnSaving script of the person table instead of the template on Person.CentralPassword.

Reply Children
  • Hello,

    Any example to save the password in the OnSaving script?

    I need to add my code below the original code, right?

    Thx!

  • Hello,

    Markus, as you said, the OnSaving is the key.

    Thank you very much, Markus and Barry!

    This is the code that I have added there:

    If NOT $[IsLoaded]:Bool$ Then

        'Chequeamos que haya First Name y Last Name
        If not String.IsNullOrEmpty($Firstname$) AndAlso not String.IsNullOrEmpty($Lastname$) Then
            Dim today As Date = DateTime.now
            Dim Password As String = ""
            Password += $FirstName$.Substring(0,1)
            Password += "*"
            If today.Day.ToString().Length = 1 Then
                Password += "0" + today.Day.ToString()
            else
                Password += today.Day.ToString()
            End If
            If today.Month.ToString().Length = 1 Then
                Password += "0" + today.Month.ToString()
            else
                Password += today.Month.ToString()
            End If
            Password += "*"
            dim PrimerApellido as String
            dim SegundoApellido as String
            If InStr($LastName$, " ") > 0 Then
                    PrimerApellido = $LastName$.Split(New Char() {" "c})(0)
                    SegundoApellido = $LastName$.Split(New Char() {" "c})(1)
                Else
                    PrimerApellido = $LastName$
                    SegundoApellido = $LastName$
                End If
            If PrimerApellido.Length > 2 then
                Password += PrimerApellido.Substring(PrimerApellido.Length - 2)
            else
                Password += PrimerApellido
            end if
            Password = Password.ToLower
            
            Entity.PutValue("CentralPassword",Password)
        end if

    End If