boolean connected = false;
if ( connection == null ) {
connection = new LDAPConnection(hostName, port, connOptions);
try {
connection.connectToHost(bindDN, bindPassword);
connected = true;
} catch (LDAPConnectionException e) {
// if connection failed, return appropriate error response
batchResponses.add(createErrorResponse(e));
}