A client application contacts a CIM Object Manager to establish a connection each time it needs to perform a WBEM operation, such as creating a CIM class or updating a CIM instance. The application uses the CIMClient class to create an instance of the client on the CIM Object Manager. The CIMClient class takes three optional arguments:
namespace
The host name and namespace to use for this client connection. The default is root\cimv2 on the local host.
user name
The name of a valid Solaris user account. The CIM Object Manager checks the access privileges for this user to determine what type of access to CIM objects is allowed. The default user account is guest.
password
The password for this user account. The password must be a valid password for the user's Solaris account. The default password is guest.
Once connected to the CIM Object Manager, all subsequent CIMClient operations occur within the specified namespace.
The following examples show two ways of using the CIMClient interface to connect to the CIM Object Manager.
In Example 6-2, the application takes all the default values. That is, it connects to the CIM Object Manager running on the local host (the same host the client application is running on), in the default namespace (root\cimv2), using the default user account and password, guest.
/* Connect to root\cimv2 namespace on the local host as user guest with password guest cc = new CIMClient(); |
In Example 6-3, the application connects to namespace A on host happy. The application first creates an instance of a namespace to contain the string name of the namespace (A). Next the application uses the CIMClient class to connect to the CIM Object Manager, passing it the namespace object, user name, and host name.
/* Create a namespace object initialized with A (name of namespace) on host happy. CIMNameSpace cns = new CIMNameSpace("happy", A); // Connect to the namespace as user Mary. cc = new CIMClient(cns, "Mary", ""); |