docs: @Override
      public DfsReferralData getDfsReferrals ( CIFSContext ctx, String path, String targetHost, String targetDomain, int rn ) throws CIFSException {
          if ( log.isDebugEnabled() ) {
              log.debug("Resolving DFS path " + path);
          }
  
          if ( path.length() >= 2 && path.charAt(0) == '\\' && path.charAt(1) == '\\' ) {
              throw new SmbException("Path must not start with double slash: " + path);
          }
  
          try ( SmbSessionImpl sess = getSmbSession(ctx, targetHost, targetDomain);
                SmbTransportImpl transport = sess.getTransport();
                SmbTreeImpl ipc = sess.getSmbTree("IPC$", null) ) {
  
              DfsReferralRequestBuffer dfsReq = new DfsReferralRequestBuffer(path, 3);
              DfsReferralResponseBuffer dfsResp;
              if ( isSMB2() ) {
                  Smb2IoctlRequest req = new Smb2IoctlRequest(ctx.getConfig(), Smb2IoctlRequest.FSCTL_DFS_GET_REFERRALS);
                  req.setFlags(Smb2IoctlRequest.SMB2_O_IOCTL_IS_FSCTL);
                  req.setInputData(dfsReq);
                  dfsResp = ipc.send(req).getOutputData(DfsReferralResponseBuffer.class);
              }
              else {
                  Trans2GetDfsReferralResponse resp = new Trans2GetDfsReferralResponse(ctx.getConfig());
                  ipc.send(new Trans2GetDfsReferral(ctx.getConfig(), path), resp);
                  dfsResp = resp.getDfsResponse();
              }
  
              if ( dfsResp.getNumReferrals() == 0 ) {
                  return null;
              }
              else if ( rn == 0 || dfsResp.getNumReferrals() < rn ) {
                  rn = dfsResp.getNumReferrals();
              }
  
              DfsReferralDataImpl cur = null;
              long expiration = System.currentTimeMillis() + ( ctx.getConfig().getDfsTtl() * 1000 );
              Referral[] refs = dfsResp.getReferrals();
              for ( int di = 0; di < rn; di++ ) {
                  DfsReferralDataImpl dr = DfsReferralDataImpl.fromReferral(refs[ di ], path, expiration, dfsResp.getPathConsumed());
                  dr.setDomain(targetDomain);
  
                  if ( ( dfsResp.getTflags() & 0x2 ) == 0 && ( dr.getFlags() & 0x2 ) == 0 ) {
                      log.debug("Non-root referral is not final " + dfsResp);
                      dr.intermediate();
                  }
  
                  if ( cur == null ) {
                      cur = dr;
                  }
                  else {
                      cur.append(dr);
                      cur = dr;
                  }
              }
  
              if ( log.isDebugEnabled() ) {
                  log.debug("Got referral " + cur);
              }
              return cur;
          }
      }