Views:

Applies To:

GroupID 8, 9 and 10 - Synchronize

Use Case: 

Using GroupID Synchronize, is it possible to upload/sync user photos from a folder to Active Directory?

Solution:

Yes, GroupID Synchronize can be used to bulk upload photos to Active Directory.

Prerequisites:

Before you synchronize images between the file system and Active Directory, make sure that:

  • All images that need to be transferred from the file system to Active Directory are placed in a single folder.
  • The names of the image files can be based on any Active Directory attribute that uniquely identifies them, like samAccountName. It can also be a combination of two or more attributes, like firstName_lastName (e.g. john_smith.jpg).

For the purpose of demonstration, EmployeeID has been used to name the image files in the following instructions. If you are using some other attribute, please use it in place of EmployeeID where applicable.

Steps:

Use the following instructions to create a job that synchronizes images between the file system and Active Directory. If your job already exists, then open it for editing and begin at step 5. 

  1. Right-click the All Jobs node in Synchronize and then click New Job. This launches the New Job wizard.

  2. On the Select Source Provider page, use the Select a provider for the source list to select Microsoft Active Directory (LDAP) – also supports Microsoft Exchange. This shows the settings that are required to connect to the selected source. Configure these settings according to your environment. Click Next to continue when you are done.

  3. On the Select Destination Provider page, again select Microsoft Active Directory (LDAP) – also supports Microsoft Exchange as the destination and configure the settings accordingly. Click Next to continue.

  4. On the Create Object page, keep the default option Skip selected and click Next.

  5. On the Select Destination Fields page, make sure that all the required fields that need to be synced are included in the Selected Fields list; here, EmployeeID and thumbnailPhoto.

  6. Click Next.

  7. On the Fields Map(s) page, select the check boxes in the Key and New only columns for EmployeeID. Please note that the primary key EmployeeID, in this case, is mapped to itself.

  8. Click the button in the Transform column for thumbnailPhoto. On the Transform dialog box, select Static  assign a static value in the given list and then type Null in the Static text boxClick OK.

  9. Next, click Edit Global Script to launch the Global Script Editor. 

  10. On the menu, click Tools and then click Reference to check if the reference to Active Directory PowerTool DLL is included. If not, then click Browse, go to [GroupID Installation Directory]\Synchronize\PowerTools and select Synchronize.ActiveDirectoryTool.dll.

  11. Locate the DTM_RowFinishing event and update it according to the following code segment.

    Sub DTM_RowFinishing(ByVal dtmsource As Object, ByVal args As JobEventArgs) Handles DTM.RowFinishing
              Dim pic As String = DTM.Source("employeeID")
              Dim imagePath As String
              imagePath = "C:\Photos\" & pic & ".jpg"
              Dim thumbnailImageArray () As Byte
              Dim inFile As New System.IO.FileStream(imagePath, System.IO.FileMode.Open,
              System.IO.FileAccess.Read)
              Dim binaryData(inFile.Length - 1) As Byte
              Dim bytesRead As Integer = inFile.Read(binaryData, 0, CType(inFile.Length,Integer))
              inFile.Close()
              Try
                              ActiveDirectoryTool.ConfigureFromDestination()
                              thumbnailImageArray = ActiveDirectoryTool.GetThumbnailPhoto(binaryData)
              args.SetStagingDestination("thumbnailPhoto",thumbnailImageArray)
              Catch ex As Exception
              ' Msgbox(ex.message)
              End Try
        End Sub
  12. On the menu, click Build and then Compile Script. Save the script and then close Global Script Editor.

  13. With the script added and the fields mapped, you have completed the main requirement for synchronizing the image files between the file system and Active Directory. Click Next.

  14. On the Configure Notifications page, specify the notification settings as per your requirement and click Next.

  15. On the Save Job page, specify a name for your job and then click Finish. Run your job to test if it works as expected.

Known Issue:

The old and previous values in job results are shown in bits instead of images.

Important:

  1. If you are using a different attribute, change the part of the script highlighted in orange. DTM.Source can be any attribute in Active Directory, like employeeID or samAccountName.
  2. Image path (highlighted text in red) indicates the path of the folder containing the image files and format of pictures. Update this path and format according to your environment.