2011-08-04 31 views
0

を取得jinterop:私は以下のコードを実行すると、Windowsのイベントログ

JISession dcomSession = JISession.createSession(domain, user, pass); 
dcomSession.useSessionSecurity(false); 
JIProgId id = JIProgId.valueOf("WbemScripting.SWbemLocator"); 
id.setAutoRegistration(true); 
JIComServer wbemLocatorComObj = new JIComServer(id, host,dcomSession); 

例外が発生します。

org.jinterop.dcom.common.JIException: Access is denied, please check whether the [domain-username-password] are correct. Also, if not already done please check the GETTING STARTED and FAQ sections in readme.htm. They provide information on how to correctly configure the Windows machine for DCOM access, so as to avoid such exceptions. [0x00000005] 
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_CreateKey(JIWinRegStub.java:310) 
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:510) 
    at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:414) 
    at main.java.EventLogListener.getWmiLocator(EventLogListener.java:43) 
    at main.java.EventLogListener.main(EventLogListener.java:87) 
Caused by: org.jinterop.dcom.common.JIRuntimeException: Access is denied, please check whether the [domain-username-password] are correct. Also, if not already done please check the GETTING STARTED and FAQ sections in readme.htm. They provide information on how to correctly configure the Windows machine for DCOM access, so as to avoid such exceptions. [0x00000005] 
    at org.jinterop.winreg.IJIWinReg$createKey.read(IJIWinReg.java:459) 
    at ndr.NdrObject.decode(NdrObject.java:36) 
    at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:137) 
    at rpc.Stub.call(Stub.java:113) 
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_CreateKey(JIWinRegStub.java:304) 
    ... 4 more 

それが動作するときJIProgId id = JIProgId.valueOf("InternetExplorer.Application"); I「は、ホストdomianユーザのパスワードがOKである確信していますなぜ上はうまくいかないのですか?

お願いします。

+0

管理者レベルの資格情報を使用していますか? – nIKUNJ

+0

この場合、管理者である必要はありません。 – AlexR

答えて

0

は、このコードに見てみましょう:

import static org.jinterop.dcom.impls.JIObjectFactory.narrowObject; 
import static org.jinterop.dcom.impls.automation.IJIDispatch.IID; 

JISession dcomSession = JISession.createSession(domain, user, pass); 
JIComServer comServer = new JIComServer(valueOf("WbemScripting.SWbemLocator"), hostname, dcomSession); 
IJIDispatch wbemLocator = (IJIDispatch) narrowObject(comServer.createInstance().queryInterface(IID)); 

Object[] params = new Object[] { 
     new JIString(hostname), 
     new JIString("ROOT\\CIMV2"), 
     JIVariant.OPTIONAL_PARAM(), 
     JIVariant.OPTIONAL_PARAM(), 
     JIVariant.OPTIONAL_PARAM(), 
     JIVariant.OPTIONAL_PARAM(), 
     new Integer(0), 
     JIVariant.OPTIONAL_PARAM() 
}; 
JIVariant results[] = wbemLocator.callMethodA("ConnectServer", params); 
IJIDispatch wbemServices = (IJIDispatch) narrowObject(results[0].getObjectAsComObject()); 

私はここでそれを見つけた:http://www.vijaykandy.com/2009/09/windows-management-instrumentation-wmi-from-java/

を私はdcomSession.useSessionSecurity(false);があなたの悩みを引き起こすことと思います。

私が参照したチュートリアルを試してみてください。私はすべてがうまくいくことを願う。

+0

あなたの助けを感謝します、ローカルマシンを接続する場合、私は私のIPでホスト名とドメインを設定することができます、これは大丈夫ですか? – user877899

+0

私はdomianかhostnameに何か問題があると思います。 – user877899

関連する問題