Ejemplo n.º 1
0
 public SampleTestServer(String address, String[] args) throws JIException, UnknownHostException {
   this.address = address;
   session = JISession.createSession(args[1], args[2], args[3]);
   comStub = new JIComServer(JIProgId.valueOf("SampleTestServer.TestServer"), address, session);
   IJIComObject unknown = comStub.createInstance();
   comObject =
       (IJIComObject)
           unknown.queryInterface("1F438B1C-02BA-462E-A971-8E0640C141E5"); // ITestServer
 }
  public WindowsHealth(
      String address, String domain, String user, String passwd, int timeout, boolean verbose)
      throws JIException, UnknownHostException {
    if (verbose) System.out.print("Creating session... ");
    session = JISession.createSession(domain, user, passwd);
    session.useSessionSecurity(true);
    session.setGlobalSocketTimeout(timeout);

    if (verbose) {
      System.out.println("OK");
      System.out.print("Connecting to COMServer... ");
    }

    JIProgId progid = JIProgId.valueOf("WbemScripting.SWbemLocator");
    comStub = new JIComServer(progid, address, session);
    IJIComObject unknown = comStub.createInstance();
    comObject =
        (IJIComObject)
            unknown.queryInterface("76A6415B-CB41-11d1-8B02-00600806D9B6"); // ISWbemLocator

    if (verbose) {
      System.out.println("OK");
      System.out.print("Connecting to targethost... ");
    }

    dispatch =
        (IJIDispatch) JIObjectFactory.narrowObject(comObject.queryInterface(IJIDispatch.IID));
    service =
        dispatch
            .callMethodA(
                "ConnectServer",
                new Object[] {
                  new JIString(address),
                  JIVariant.OPTIONAL_PARAM(),
                  JIVariant.OPTIONAL_PARAM(),
                  JIVariant.OPTIONAL_PARAM(),
                  JIVariant.OPTIONAL_PARAM(),
                  JIVariant.OPTIONAL_PARAM(),
                  new Integer(0),
                  JIVariant.OPTIONAL_PARAM()
                })[0];

    service_dispatch = (IJIDispatch) JIObjectFactory.narrowObject(service.getObjectAsComObject());
    if (verbose) System.out.println("OK");

    percentprocessortime = -1;
    timestamp = -1;
  }