public static String standardise(String dn,
Converts a DN string into a "standard"
DN string representation consumable by
This is particularly useful when matching
group memberDNs to entity DNs as the two
DN formats need to be equivalent.
AD returns DN's that have mixed case attribute labels, eg. member attribute might look like: CN=user-1100,CN=Users,DC=sydney,DC=atlassian,DC=com for AD.
Since everything goes through a dirContextAdapter (thanks for coming in: SpringLDAP), when we call context.getDn()
in the UserContextMapper/GroupContextMapper, the DN we get back is a SpringLDAP parsed DN (ie. forces lower-casing of
attribute names). However, when we get back memberDNs for a group, these attributes values are pure String representaions
of the DN returned from the server. This will cause the memberDN to not match the DN of any object previously seen as
the memberDN will not be forced toLowerCase or forced to compaction (",") or comma-space-delimmition (", ") for RDN
components of the memberDN.
It is critical that the DN and memberDN are comparable based on a raw String comparison (String.equals)
for things like group membership determination and cache consistency.
Therefore, if it is known that
the directory server always returns DNs
that do not have ", " but have "," separating
the naming components, then we do not need
to force "proper" (ie. complete + expensive)
standardisation. Thus if forceProperStandard
is false, then the compact (spaceless)
comma delimited DNs are transformed to lower case.
This method assumes that the DNs are case-insensitive.
If it is not known whether the directory server
will return spaceless or spaced commas, we need
to use the full DN standardisation. Set
forceProperStandard to true
for the significantly slower, 100% effective,
standardisation. This method also assumes nothing
about the case of DNs.
dn - original DN.
forceProperStandard - true if you
want to enforce the slow but effective standardisation process.
DN in standard form.
public static String standardise(LdapName name,