79354821

Date: 2025-01-14 11:19:30
Score: 0.5
Natty:
Report link

First we need to encode the objectGUID byte array into a hexadecimal representation with escaped backslashes () for each byte

private String encodeToHexWithEscape(byte[] bytes) {
    StringBuilder hexBuilder = new StringBuilder();
    for (byte b : bytes) {
        // Format each byte as a two-digit hex value with a leading backslash
        hexBuilder.append(String.format("\\%02X", b & 0xFF));
    }
    return hexBuilder.toString();
}

Then use it in filter for ldap search:

String hexEncodedGUID = encodeToHexWithEscape(objectGUID);
String filter = String.format("(objectGUID=%s)", hexEncodedGUID);

// Perform the search
ldapTemplate.search(
        "", // Base DN (modify according to your directory structure)
        filter,
        new MyContextMapper()
);
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Aragorn