How to create an ad account in the right target organizational unit based on attributes of the user identity record in OIM

I would like to create an AD account in an organizational unit depending on the values given in the attributes given in the user file in OIM, that is if we have an A and B in the customattribute1 and 2 we create the account in the 'OR' A and if we have for example another case where we have a value B and A in the customattribute1 and 2 we create the account in the organizational unit B; In my case, I can't use the department nor the cost center nor the business role so i can't use the function itmappingdata  on the manager

  • Hey.

    This is how I solved it (not saying it's the best solution)

    This is the value calculation (template) for ADSAccount.UID_ADSContainer:

    If CBool(Connection.Variables.Get("FULLSYNC")) = False Then
        'I'm not sure that IndexOf works here
    	If $FK(UID_Person).CustomProperty01$.IndexOf("A") > 0 Or
    	   $FK(UID_Person).CustomProperty02$.IndexOf("B") > 0 Then
    			Value = CCC_GetADSContainer($FK(UID_Person).CustomProperty01$, $FK(UID_Person).CustomProperty02$)
    	End If
    End If

    And this is the script:

    Public Function CCC_GetADSContainer (ByVal CustomProperty01 As String, ByVal CustomProperty02 As String) As String	
    	Dim f As ISqlFormatter = Session.SqlFormatter
    	Dim ADSContainer As String = ""
    	Dim where As String = ""
    	
    	CustomProperty01 = CustomProperty01.ToUpper
    	CustomProperty02 = CustomProperty02.ToUpper
    
    	CustomProperty = CustomProperty01 & CustomProperty02
    
    	Select Case CustomProperty
    		Case "A"
    	 		where = f.Comparison("DistinguishedName", Session.Config.GetConfigParm("Custom\Targetsystem\ADS\ADSContainer\[Suitable name for a ConfigParm]"),ValType.String)
    		Case "B"
    	 		where = f.Comparison("DistinguishedName", Session.Config.GetConfigParm("Custom\Targetsystem\ADS\ADSContainer\[Suitable name for a ConfigParm]"),ValType.String)
    		Case "AB"
    	 		where = f.Comparison("DistinguishedName", Session.Config.GetConfigParm("Custom\Targetsystem\ADS\ADSContainer\[Suitable name for a ConfigParm]"),ValType.String)
    		Case "BA"
    	 		where = f.Comparison("DistinguishedName", Session.Config.GetConfigParm("Custom\Targetsystem\ADS\ADSContainer\[Suitable name for a ConfigParm]"),ValType.String)
    		End Select
    
    	ADSContainer = Session.Source.GetSingleValue(Of String)("ADSContainer", "UID_ADSContainer", where).ToString
    
    	Return ADSContainer
    End Function

    The configParm should of course be the UID for ADSContainer where you want to put the account.

    Hth

    Henrik

    PS. I think it's funny that on a forum for a program that is coded with VB, one can't select VB as the selected lagnuage when inserting code..

  • Hi,

    I think there are several ways to address this scenario. 

    I'd suggest checking the template for the UID_ADSContainer (OrganizationalUnit) column in the ADSAccount table. There you'll find how it behaves depending on the itmappingdata you've defined in Manager. The template in Value calculation is a vb script , so you can modify it to fill in the appropriate UID_ADSContainer depending on your needs,  let's say, values in the $FK(UID_Person).CustomAttribute1$ column.

    HtH!