Can't query MWS users by Middle Name from Java-Service

There are some users created in the MWS (User Management of MWS) with some optional fields filled-in, among others “Middle Name”. Our java service implementation uses Directory Services and searches the specific user with “Middle Name” parameter included as follows:

try (IDirectorySession session = DirectorySystemFactory.getDirectorySystem().createSession()) {
    IDirectoryPagingCookie cookie = session.createPagingCookie(IDirectoryService.SYSTEM_DIRECTORY_SERVICE_ID);
    DirectorySearchQuery query = new DirectorySearchQuery(null, -1,
                                                          new DirectorySearchQuery.RefineQueryField[] { new DirectorySearchQuery.RefineQueryField(IDirectoryPrincipal.ATTR_NAMES.PROFILE_MIDDLE_NAME, "search string") } 
                                                          );
    List<IDirectoryPrincipal> users = session.searchDirectory(IDirectoryService.SYSTEM_DIRECTORY_SERVICE_ID, IDirectoryPrincipal.TYPE_USER, query, cookie);
    JournalLogger.logDebug(3, JournalLogger.FAC_FLOW_SVC, "Found users: " + cookie.getTotal());
    for (IDirectoryPrincipal p : users) {
      JournalLogger.logDebug(3, JournalLogger.FAC_FLOW_SVC, "Found user: " + p.getName());
    }
    session.destroyPagingCookie(cookie);
} catch (DirectoryException e) {
    JournalLogger.logError(3, JournalLogger.FAC_FLOW_SVC, "Directory error: " + e.getMessage());
}

The thing is the source code returns all users which means the “Middle Name” parameter does not impact the query.
We would like to get some advice how to implement the search so that the optional parameters could be fully used within the User search.