Check whether a value is unique in a system

Sometimes it is necessary to generate attributes like username or email which are unique even in a certain system (e. g., MS AD). However, not every user in the system must be in IdM. In some cases, historical accounts still exist or IdM manages only a part of the system. For these reasons, a service which enables you to search a system and check that an attribute value is unique was created.

This is a backend-only implementation that can be used in your scripts. The usage is quite simple. The service DefaultExtrasSystemUniquenessValidationService has two methods to check that a value is unique. The only difference is how you specify the system. One expects the object SysSystemDto, the other uses only the ID of the system.

Let's take a look at an example:

boolean unique = defaultExtrasSystemUniquenessValidationService.isValueUnique(systemId, attributeName, value, "EQUALS");

where:

  • systemId is a UUID of the system (UUID type)
  • attributeName is a name of the attribute in the system (String type)
  • value is a value whose uniqueness we are checking (String type)
  • "EQUALS" is a type of comparison, in this case, we are looking for values that are an exact match (see below for other types of comparison)

Multivalued attributes are supported as well.

Only connId connectors are supported. In practice, this only means that the service cannot be used for virtual systems.

The following comparison types are supported:

  • CONTAINS - check that the system contains an attribute whose value contains the tested value, i. e., we are looking for a partial match
  • ENDSWITH - check that the system contains an attribute whose value ends with the tested value
  • EQUALS - check that the system contains an attribute whose value is an exact match to the tested value
  • STARTS_WITH - check that the system contains an attribute whose value starts with the tested value

You can either use the comparison type values directly (as seen above) or use the constants in the ExtrasComparison class.

  • by doischert