예제 #1
0
  /**
   * Entry point.
   *
   * @param args[0] Domain controller name.
   * @param args[1] Domain user name.
   * @param args[2] Domain password.
   * @param args[3] Optional file name. Default is mp3Spider.out
   */
  public static void main(String args[]) throws IOException, InterruptedException {

    String domCtrl = null;
    String domName = null;
    String domUser = null;
    String domPass = null;
    // File to write to
    FileWriter fwrite = null;

    try {
      domCtrl = args[0];
      domName = args[1];
      domUser = args[2];
      domPass = args[3];
    } catch (ArrayIndexOutOfBoundsException e) {
      System.err.println("Usage:");
      System.err.println(
          "java mp3Spider <Domain controller> "
              + "<Domain Name> <Username> <Password> [<Out file>]");
      System.exit(1);
    }

    if (args.length == 5) fwrite = new FileWriter(args[5]);
    else fwrite = new FileWriter("mp3Spider.out");

    // Get list of machines on the domain
    CifsLogin login = new CifsLogin(domUser, domPass);
    CifsRemoteAdmin admin = null;
    CifsServerInfo mach[] = null;
    try {
      admin = CifsSessionManager.connectRemoteAdmin("Mach_list_all", domCtrl, login);

      mach = admin.listServersInfo(domName, CifsServerInfo.SV_TYPE_ALL);
      admin.disconnect();
    } catch (CifsIOException e) {
      System.err.println("Session failed: " + e);
      e.printStackTrace();
      System.exit(1);
    }

    // Create a thread and start shareVu() for every machine
    ShareVu t[] = new ShareVu[mach.length];
    for (int i = 0; i < mach.length; i++) {
      System.out.println("Mach: " + mach[i].getComputerName());
      // Create the thread
      t[i] = new ShareVu(mach[i].getComputerName(), login, fwrite);
    }

    // Wait for all threads to finito

    for (int i = 0; i < mach.length; i++) {
      try {
        t[i].t.join();
      } catch (InterruptedException e) {
        System.out.println("Join error " + e);
      }
    }
  }
예제 #2
0
  static CifsIOException getLMException(int code) {

    CifsIOException e = new CifsIOException();

    try {
      e.fMessage = CifsRuntimeException.getMessage("LM" + code);
    } catch (Exception ex) {
      e.fMessage = CifsRuntimeException.getMessage("LMERROR", new Integer(code));
      if (Debug.debugOn) Debug.println(Debug.WARNING, "LM Error:" + code + " not defined");
    }
    return e;
  }
예제 #3
0
  static CifsIOException getNBException(int code) {

    CifsIOException e = new CifsIOException();

    try {
      e.fMessage = CifsRuntimeException.getMessage("NB" + code);
    } catch (Exception ex) {
      e.fMessage = CifsRuntimeException.getMessage("NB9999", new Integer(code));
    }

    return e;
  }