Is there a script for populating the AD from a Data Source? (NETIQKB4834)

  • 7704834
  • 02-Feb-2007
  • 06-Mar-2008

Resolution

goal
Is there a script for populating the AD from a Data Source?

fact
Domain Migration Administrator 6.x

fact
Domain Migration Administrator 7.x

fix

This sample script allows you to populate properties of migrated accounts in the Active Directory from an external data source, such as a .csv file or an ODBC database. This sample script is written in VBscript and uses the ODBC OLE DB provider to request information from an ODBC compliant data source. You need to modify the script to meet your specific needs, such as specifying the appropriate data source connection and the data SELECT statement.

This post-user migration script demonstrates how to use a .csv file called PropList.csv as an external data source. The first line of the .csv file must provide the Active Directory property names. The first property must be objName, which uniquely identifies each account. The objName property value must match the samAccountName property of the account. Each additional line in the .csv file provides the property values for the target accounts in the Active Directory. This script must be specified as a VBScript. The script will be run during the user migration. As each target user is created, the additional AD properties will be populated from the values in the .csv file.

For example, the PropList.csv file could be similar to the following example:


objName,givenName,sn,telephoneNumber,streetAddress,L,st,postalCode
ashleym,Ashley,Mueller,713-555-1212,5100 Carew St,Houston,Texas,77096
frankw,Frank,West,281-555-1212,5200 Indigo St,Houston,Texas,77096
janeg,Jane,Getz,713-548-1700,13939 NW Frwy,Houston,Texas,77040

The following script reads the values in this PropList.csv file and uses those values to populate the properties of the identified accounts in the Active Directory.

' This script updates properties of accounts in the Active Directory
' using values from an external data source, such as a csv file.

Sub Process()
  Dim con
  Dim rs
  Dim name
  Dim fieldNum

  ' Get the name of the account being processed by DMA
  name = Settings.get("CopiedAccount.TargetSam")

PAN style="FONT-SIZE: 8pt; mso-bidi-font-size: 12.0pt">

  ' Open the connection to the data source
  Set con = CreateObject("ADODB.Connection")

  ' Open the data source.
  ' In this sample, the data source name is PropList.
  ' This ODBC data source identifies the PropList.csv file.
  ' You can change the following open connection call to connect
  ' to any OLE DB provider.
  con.Open "DSN=PropList"

  ' Collect a recordset from the open data source.
  ' The following query provides a recordset from the data source.
  ' The first column name is objName, which uniquely identifies
  ' each account. The objName property value must match the
  ' samAccountName property of the account in the source domain.
  ' You can customize this SELECT statement for your specific 
  ' data source table name and your OLE DB provider.
  Set rs = con.Execute("Select * from PropList.csv")

  ' Search the recordset for the account being processed by DMA
  rs.Filter = "objName = '" + name + "'"
  rs.Requery

  ' If the record exists, update the account properties 
  ' with the associated values in the recordset.
  If (Not rs.EOF) Then
   For fieldNum = 1 To rs.Fields.Count - 1
     TargetObject.Put rs.Fields(fieldNum).name, rs.Fields(fieldNum).Value
   Next
   TargetObject.SetInfo
  End If
End Sub

.


note
Please note that this information can also be obtained from Chapter 3 of the product User Guide.

Additional Information

Formerly known as NETIQKB4834