Hey Folks,
I am having a weird issue with template updates on ADSaccount CN created as part of an account definition.
Breakdown is as follows:
- Account Definition SO is created.
- Manage level SO FM is created.
- Account Definition is assigned to Business Role.
- Custom templates created to properly populate CN and SAMACCOUNTNAME.
When the role is selected as the person's primary biz role, the CN and SAMACCOUNTNAME are properly pre-pended with an "SO-" with the account creation.
The strange thing is that If I look at the object in manager and re-apply the template, the CN changes to a string of "SO-SO-SO-SO-SO" to the max length of the field it seems.
I am including the edited custom template code below (my custom code is between lines (25-47):
If Not CBool(Variables("FULLSYNC")) AndAlso Not ($cn$).Contains(Chr(10)) Then Dim CN, CNfix, DNold, DNnew,Domain, wherePart As String Dim i As Integer Dim f As ISqlFormatter = Connection.SqlFormatter If $Givenname$ <> $Givenname[o]$ Or $Surname$ <> $Surname[o]$ Then If $Givenname$<>"" AndAlso $Surname$<>"" Then CN = $Surname$ & " " & $Givenname$ ElseIf $Givenname$<>"" Then CN = $Givenname$ ElseIf $Surname$<>"" Then CN = $Surname$ Else CN = $cn$ End If Else CN = $cn$ End If Dim cnLen as Integer = Base.TableDef.Columns("CN").MaxLen CN = VID_Left(CN, cnLen) '=> Check for Account Definitions and set CN based on Account Definition Requirements. select case $FK(UID_TSBBehavior).Ident_TSBBehavior$.ToUpper() '=> BXIILAB SU Account CN case "ELV FM SU ACCOUNT BXIILAB" CN = "SU" + "-" + VID_Left(CN, (cnLen -4)) '=> BXIILAB SO Account CN case "ELV FM SO ACCOUNT BXIILAB" CN = "SO" + "-" + VID_Left(CN, (cnLen -4)) '=> BXIILAB SG Account CN case "ELV FM SG ACCOUNT BXIILAB" CN = "SG" + "-" + VID_Left(CN, (cnLen -4)) '=> BXIILAB DA Account CN case "ELV FM DA ACCOUNT BXIILAB" CN = "DA" + "-" + VID_Left(CN, (cnLen -4)) case else CN = VID_Left(CN, cnLen) end select If $cn[o]$<>CN Or $UID_ADSContainer[o]$<>$UID_ADSContainer$ Then i=1 CNFix = CN If $UID_ADSContainer[o]$ <> "" Then DNold = $FK(UID_ADSContainer[o]).DistinguishedName$ Else DNold = $FK(UID_ADSDomain[o]).DistinguishedName$ End If If $UID_ADSContainer$ <> "" Then DNnew = $FK(UID_ADSContainer).DistinguishedName$ Else DNnew = $FK(UID_ADSDomain).DistinguishedName$ End If Domain = $UID_ADSDomain$ If DNold <> "" And DNold <> DNnew Then wherePart = f.OrRelation( _ f.Comparison("DistinguishedName", ADS_CreateDN("cn", CN, DNnew), ValType.String), _ f.Comparison("DistinguishedName", ADS_CreateDN("cn", CN, DNold), ValType.String) _ ) Else wherePart = f.Comparison("DistinguishedName", ADS_CreateDN("cn", CN, DNnew), ValType.String) End If Do While Connection.Exists( "ADSAccount", _ f.AndRelation( _ f.UidComparison("UID_ADSAccount", $UID_ADSAccount$, CompareOperator.NotEqual), _ f.UidComparison("UID_ADSDomain", Domain), _ wherePart _ )) CN = VID_Left(CNfix, cnLen - (1 + CStr(i).Length)) & "_" & i If DNold <> "" And DNold <> DNnew Then wherePart = f.OrRelation( _ f.Comparison("DistinguishedName", ADS_CreateDN("cn", CN, DNnew), ValType.String), _ f.Comparison("DistinguishedName", ADS_CreateDN("cn", CN, DNold), ValType.String) _ ) Else wherePart = f.Comparison("DistinguishedName", ADS_CreateDN("cn", CN, DNnew), ValType.String) End If i=i+1 Loop End If Value = CN End If
I am hoping that I am totally missing something obvious and that it is not some bug.
Thanks for the help!