public static Collection<LdapEntry> readLdif(final InputStream ldif, final String baseDn) throws IOException {
        var ldapString = StringUtils.EMPTY;
        try (val reader = new BufferedReader(new InputStreamReader(ldif, StandardCharsets.UTF_8))) {
            ldapString = reader.lines()
                .map(line -> {
                    LOGGER.debug("Reading LDAP entry line [{}]", line);
                    if (line.contains(BASE_DN_PLACEHOLDER)) {
                        return line.replace(BASE_DN_PLACEHOLDER, baseDn);
                    }
                    return line;
                })
                .collect(Collectors.joining(NEWLINE));
            LOGGER.debug("LDIF to process is [{}]", ldapString);
            val entries = new LdifReader(new StringReader(ldapString)).read().getEntries();
            LOGGER.debug("Total entries read from LDIF are [{}] with baseDn [{}]", entries.size(), baseDn);
            return entries;
        }
    }
Reads an LDIF into a collection of LDAP entries. The components performs a simple property
replacement in the LDIF data where &lt;pre&gt;${ldapBaseDn}&lt;/pre&gt; is replaced with the environment-specific base
DN.

@param ldif   LDIF resource, typically a file on filesystem or classpath.
@param baseDn The directory branch where the entry resides.
@return LDAP entries contained in the LDIF.
@throws IOException On IO errors reading LDIF.
support/cas-server-support-ldap-core/src/test/java/org/apereo/cas/util/LdapTestUtils.java