Extending Profile Field Types for the Sitecore Active Directory Module

Learn how to extend the Sitecore Active Directory module to support additional field types, including binary data like user photos. This guide walks through the necessary code changes and configuration updates to handle byte[] fields effectively.

Extending Profile Field Types for the Sitecore Active Directory Module
Photo by Markus Spiske / Unsplash

The Sitecore Active Directory module provides integration between one or more Active Directory domains and Sitecore. By default, it supports reading and writing basic data types such as string, int, and bool. However, a common Active Directory data type, byte[], is not supported out of the box.

Sitecore handles all Active Directory values as strings, converting types to and from string at runtime. There is no technical limitation preventing additional types like byte[] from being supported. By overriding Sitecore’s default behavior, custom types can be added while allowing Sitecore to continue handling the standard types.


Enabling Support for byte[]

Adding support for byte[] fields involves three main steps:

  1. Create a Custom StringSettingsPropertyValue Implementation
  2. Override the Default SettingsPropertyValueFactory
  3. Update Sitecore Configuration

Create a Custom StringSettingsPropertyValue

This custom implementation handles reading and writing byte[] fields by converting the data to and from Base64 strings.

Override the Default SettingsPropertyValueFactory

To make Sitecore aware of the new implementation, extend the SettingsPropertyValueFactory and add handling for the byte array type.

Update Sitecore Configuration

Finally, update the LDAP.config file to reference the new factory implementation:

Update any profile fields that require the byte[] type. For example, to store a profile photo:

With these changes in place, Sitecore can now read and write byte[] fields from Active Directory, providing proper handling for scenarios like user profile photos or other binary data fields. This approach integrates seamlessly with existing functionality while extending support for additional data types.