cn.chenlichao.wmi4j
类 SWbemLocator

java.lang.Object
  继承者 cn.chenlichao.wmi4j.SWbemLocator

public class SWbemLocator
extends Object

You can use the methods of the SWbemLocator object to obtain an SWbemServices object that represents a connection to a namespace on either a local computer or a remote host computer. You can then use the methods of the SWbemServices object to access WMI.

Created by chenlichao on 14-7-17.


构造方法摘要
SWbemLocator(String server, String username, String password, String namespace)
           
 
方法摘要
 SWbemServices connectServer()
          Use default parameters for connectServer(String, String, cn.chenlichao.wmi4j.consts.Flags.SecurityFlag, SWbemNamedValueSet)
 SWbemServices connectServer(String locale, String authority, Flags.SecurityFlag securityFlag, SWbemNamedValueSet objwbemNamedValueSet)
          The ConnectServer method of the SWbemLocator object connects to the namespace on the computer that is specified in the strServer parameter.
<T> T
createObject(Class<T> objectType)
           
 void disconnect()
          Disconnect from server and release resources
 SWbemServices getSWbemServices()
          Obtain SWbemServices object; Note: Before call this method, you need call connectServer first, to generate SWbemServices object.
 boolean isConnected()
          Verify if the connection is living.
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

SWbemLocator

public SWbemLocator(String server,
                    String username,
                    String password,
                    String namespace)
参数:
server - Computer name or ip to which you are connecting.
username - User name to use to connect. The string can be in the form of either a user name or a Domain\Username.
password - String that specifies the password to use when attempting to connect.
namespace - String that specifies the namespace to which you log on.

Note: Optional parameter, if you set it to null, then use the default namespace root\CIMv2

方法详细信息

connectServer

public SWbemServices connectServer(String locale,
                                   String authority,
                                   Flags.SecurityFlag securityFlag,
                                   SWbemNamedValueSet objwbemNamedValueSet)
                            throws WMIException,
                                   UnknownHostException

The ConnectServer method of the SWbemLocator object connects to the namespace on the computer that is specified in the strServer parameter. The target computer can be either local or remote, but it must have WMI installed. For examples and a comparison with the moniker type of connection, see Creating a WMI Script.

Starting with Windows Vista, SWbemLocator.connectServer can connect with computers running IPv6 using an IPv6 address in the strServer parameter. For more information, see IPv6 and IPv4 Support in WMI.

Windows Server 2003 and Windows XP: You only can use SWbemLocator.connectServer to connect to computers with IPv4 addresses.

参数:
locale - Optional. String that specifies the localization code. If you want to use the current locale, set to null. If not null, this parameter must be a string that indicates the desired locale where information must be retrieved. For Microsoft locale identifiers, the format of the string is "MS_xxxx", where xxxx is a string in the hexadecimal form that indicates the LCID. For example, American English would appear as "MS_409".
authority - Optional. This parameter is optional. However, if it is specified, only Kerberos or NTLMDomain can be used.

If the strAuthority parameter begins with the string "Kerberos:", then Kerberos authentication is used and this parameter should contain a Kerberos principal name. The Kerberos principal name is specified as Kerberos:domain, such as Kerberos:fabrikam where fabrikam is the server to which you are attempting to connect.
Example: "Kerberos:DOMAIN"

To use NT Lan Manager (NTLM) authentication, you must specify it as NTLMDomain:domain, such as NTLMDomain:fabrikam where fabrikam is the name of the domain.
Example: "NTLMDomain:DOMAIN"

securityFlag - Optional. Used to pass flag values to connectServer method.
objwbemNamedValueSet - Optional. Typically, this is undefined. Otherwise, this is an SWbemNamedValueSet object whose elements represent the context information that can be used by the provider that is servicing the request. A provider that supports or requires such information must document the recognized value names, data type of the value, allowed values, and semantics.
返回:
If successful, WMI returns an SWbemServices object that is bound to the namespace that is specified in namespace parameter on the computer that is specified in server parameter.
抛出:
WMIException - Failed to connect to the server.
UnknownHostException

connectServer

public SWbemServices connectServer()
                            throws WMIException,
                                   UnknownHostException
Use default parameters for connectServer(String, String, cn.chenlichao.wmi4j.consts.Flags.SecurityFlag, SWbemNamedValueSet)

返回:
抛出:
WMIException
UnknownHostException

getSWbemServices

public SWbemServices getSWbemServices()
Obtain SWbemServices object;

Note: Before call this method, you need call connectServer first, to generate SWbemServices object.

返回:
SWbemServices object
抛出:
IllegalStateException - If call before connect to the server.

createObject

public <T> T createObject(Class<T> objectType)
               throws WMIException
抛出:
WMIException

disconnect

public void disconnect()
                throws WMIException
Disconnect from server and release resources

抛出:
WMIException

isConnected

public boolean isConnected()
Verify if the connection is living.

返回:
true if living, false if dead.


Copyright © 2014. All rights reserved.