Base, One, Sub, Children
};
public static List<LdifRecord> doLdapQuery(OpsTarget target, LdapDN bindDN, String ldapPassword,
LdapDN searchBaseDN, String filter, SearchScope searchScope) throws OpsException {
Command command = Command.build(CMD_LDAP_SEARCH);
command.addLiteral("-LLL"); // Pure LDIF, no extra junk
command.addLiteral("-x"); // Simple auth
command.addLiteral("-D"); // Bind DN
command.addQuoted(bindDN.toLdifEncoded());
command.addLiteral("-w"); // Simple auth password
command.addQuoted(ldapPassword);
command.addLiteral("-b"); // Search base
command.addQuoted(searchBaseDN.toLdifEncoded());
command.addLiteral("-s"); // Scope
command.addLiteral(searchScope.toString().toLowerCase());
if (!Strings.isNullOrEmpty(filter)) {
command.addQuoted(filter);
}
ProcessExecution processExecution = target.executeCommand(command);
return LdifRecord.parse(processExecution.getStdOut());