1. Overview of Solaris Web-Based Enterprise Management
2. Using the CIM Object Manager
Sequence of a Client Application
Performing Basic Client Operations
Getting and Setting Properties
Passing a Class to the Association Methods
Passing Instances to the Association Methods
Using Optional Arguments With the Association Methods
To Set Access Control for a User
To Set Access Control for a Name Space
Working With Qualifiers and Qualifier Types
Getting and Setting CIM Qualifiers
Binding an Event Filter to an Event Handler
Reading and Writing Log Messages
A client application must first establish a connection with the CIMOM before the client can perform WBEM operations. These operations might include adding, modifying, or deleting a CIM class, CIM instance, or CIM qualifier type. The client application and CIM Object Manager can run on the same host or on different hosts. In addition, multiple clients can establish connections to the same CIM Object Manager.
When an application connects to the CIMOM, the application must also connect to a name space, where all subsequent operations occur. A name space is a directory-like structure that contains classes, instances, and qualifier types. The names of all objects within a name space must be unique. When you install the Solaris WBEM SDK, four name spaces are created:
root\cimv2 – The default name space. Contains the CIM classes that represent objects on the system on which Solaris WBEM software is installed.
root\snmp – Contains the SNMP adapter classes.
root\system – Contains the classes that manage the CIM Object Manager.
To open a client connection, you use the CIMClient class to connect to the CIM Object Manager. The CIMClient class takes four arguments:
name – Required. An instance of a CIMNameSpace object that contains the name of the host and the name space used for the client connection. The default value is root\cimv2 on the local host. The local host is the same host in which the client application is running. Once the client is connected to the CIMOM, all subsequent CIMClient operations occur within the specified name space.
principal – Required. An instance of a UserPrincipal object that contains the name of a valid Solaris OS user account. The CIMOM checks the access privileges for the user name to determine the type of access that is allowed to CIM objects.
credential – Required. An instance of a PasswordCredential object that contains a valid password for the UserPrincipal Solaris OS account.
protocol – Optional (string). Protocol that is used for sending messages to the CIMOM. Possible values are RMI, which is the default value, or HTTP.
Example 4-1 Connecting to the Root Account
In this example, the application connects to the CIM Object Manager running on the local host in the default name space. The application creates a UserPrincipal object for the root account, which has read and write access to all CIM objects in the default name space.
{ ... /* Create a name space object initialized with two null strings that specify the default host (the local host) and the default name space (root\cimv2).*/ CIMNameSpace cns = new CIMNameSpace("", ""); UserPrincipal up = new UserPrincipal("root"); PasswordCredential pc = new PasswordCredential("root-password"); /* Connect to the name space as root with the root password. */ CIMClient cc = new CIMClient(cns, up, pc); ... }
Example 4-2 Connecting to a User Account
In this example, the application first creates an instance of a CIMNameSpace, UserPrincipal, and PasswordCredential object. Then, the application uses the CIMClient class to pass the host name, name space, user name, and password credential in order to create a connection to the CIMOM.
{ ... /* Create a name space object initialized with A (name of name space) on host happy.*/ CIMNameSpace cns = new CIMNameSpace("happy", "A"); UserPrincipal up = new UserPrincipal("Mary"); PasswordCredential pc = new PasswordCredential("marys-password"); CIMClient cc = new CIMClient(cns, up, pc); ... }
Example 4-3 Authenticating as an RBAC Role Identity
You use the SolarisUserPrincipal and SolarisPasswordCredential classes to authenticate a user's role identity. This example authenticates as Mary and assumes the role Admin.
{ ... CIMNameSpaceRole cns = new CIMNameSpace("happy", "A"); SolarisUserPrincipal sup = new SolarisUserRolePrincipal("Mary", "Admin"); SolarisPswdCredential spc = new SolarisPswdCredential("marys-password", "admins-password"); CIMClient cc = new CIMClient(cns, sup, spc);
Use the close method of the CIMClient class to close a client connection and free the server resources used by the session.
Example 4-4 Closing a Client Connection
This example closes a client connection. The instance variable cc represents the client connection.
... cc.close(); ...