Using GroupID Synchronize, is it possible to Upload/ Sync User Photos from a Folder to Active Directory?
GroupID 8 & Above
Yes, GroupID Synchronize can be used to bulk Upload Photos in Active Directory. This enhancement is available with GroupID 7 and 8.x.
Job 1: Synchronizing Images from the File System
Before you synchronize images between the file system and Active Directory you need to make sure that:
All images that need to be transferred from the file system to Active Directory are placed in a single folder.
- Names of the image files can be based on any Active Directory attribute which uniquely identifies them like samAccountName e.g. jpg. 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 in the instructions.
Use the following instructions to create a job that synchronizes images between the file system and Active Directory. If your jobs already exist then open it for editing and begin from step 5.
- Right-click the All Jobs node in Synchronize and then click New Job. This starts the New Job
- 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. To learn more about these fields, click the Help Click Next to continue when you are done.
- On the Select Destination Provider page, again select Microsoft Active Directory (LDAP) – also supports Microsoft Exchange as the provider and configure the remaining settings accordingly. Click Next to continue.
- On the Create Object page, keep the default option Skip the object selected and click Next.
- 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. Click Next.
- On the Connect Synchronized Fields page
- Select the check boxes in the Key and New only columns for EmployeeID. Note; Primary Key, EmployeeID, in this case, is mapped to itself.
- Click the button in Transform column for thumbnailPhoto. On the Transform dialog box for this field, select Static – assign a static value in the given list and then type Null in the Static text Click OK
- Next, click Edit Global Script to launch the Global Script Editor. In the Global Script Editor
- 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 selectSynchronize.ActiveDirectoryTool.dll.
- Locate the DTM_RowFinishing event 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,
Dim binaryData(inFile.Length - 1) As Byte
Dim bytesRead As Integer = inFile.Read(binaryData, 0, CType(inFile.Length,Integer))
thumbnailImageArray = ActiveDirectoryTool.GetThumbnailPhoto(binaryData)
Catch ex As Exception
- On the menu, click Build and then Compile Script. Save the script and then close Global Script Editor.
- 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.
- On the Configure Notifications page, specify the notification settings as per your requirement and click Next.
- 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.
The values for old and previous values in Job results are shown in bits and not the images
- You are using a different attribute change the part of script highlighted in orange. DTM.Source can be any attribute in an Active Directory like "employeeID" or “samAccountName”.
- 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.