Workflow - Change Object properties

Guys

I have an update step in a work flow where I need to set the users Name (cn) attribute to lastname , firstname 

I have the Name (cn) property and Action to is Set but i am a little stuck on having set to lastname , firstname

Cheers

Craig 

Parents
  • A common mistake is trying to set the CN property which AD doesn't allow.  You can however set the Name.

    Here's how you configure your update activity (I take you up to adding the Last Name - I think you once you see that, you can figure out the rest).

    Drag the update activity in your workflow.

    The object to be updated "(Activity Target") should be set to your "workflow target" (which is the default).

    Select the property to update:

    Click Define and indicate that you are going to build the value using a rule:

    The first part of the rule will be the last name (sn)

    Select Workflow Target

    Select the last name property

    Repeat the last two steps adding your text string <comma><space> (you just type the actual space and the comma) and the first name (givenname) properties.

Reply
  • A common mistake is trying to set the CN property which AD doesn't allow.  You can however set the Name.

    Here's how you configure your update activity (I take you up to adding the Last Name - I think you once you see that, you can figure out the rest).

    Drag the update activity in your workflow.

    The object to be updated "(Activity Target") should be set to your "workflow target" (which is the default).

    Select the property to update:

    Click Define and indicate that you are going to build the value using a rule:

    The first part of the rule will be the last name (sn)

    Select Workflow Target

    Select the last name property

    Repeat the last two steps adding your text string <comma><space> (you just type the actual space and the comma) and the first name (givenname) properties.

Children
  • Hi   How can you make this workflow unique so that you don't potentially end up with 2 users in the same OU with the same CN/Distinguished name? 

  • Hi  

    The easiest (long term) method is to ensure you have a naming standard for objects that are going to reside in the same OU can never have the same name (as it contains an value from the object that is already unique, for instance

    name/cn = <FirstName><Space><Last Name><Space>(<samAccountName>)

    IE

    • John Smith (JSmith)
    • John Smith (JSmith1)

    The other methods would be to write a script to determine the new name, where it checks if the name is currently in use, then returns a valid name, in sudo code that would be along the lines of (but with appropriate functions for ARS and parameter parsing from a workflow)

    Function New-UserCN
    {
        Param
        (
            [string]$FirstName,
            [String]$LastName
        )
    
        $NewName = [string]::Format("{0} {1}",$FirstName,$LastName)
    
        $Users = (Get-QADUser -LdapFilter "(cn=$NewName*)" -DontUseDefaultIncludedProperties -UseGlobalCatalog) | Sort-Object cn
    
        If(-not $Users)
        {
            Return $NewName
        }
    
        $Digits = [int]($Users[-1].name.replace($NewName,""))
        $Digits++
        $NewName = [string]::Format("{0} {1}{2}",$FirstName,$LastName,$Digits)
        Return $NewName
    }
    
    New-UserCN -FirstName "Stu" -LastName "Pollock"