JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris WBEM Developer's Guide     Oracle Solaris 11 Express 11/10
search filter icon
search icon

Document Information


1.  Overview of Solaris Web-Based Enterprise Management

2.  Using the CIM Object Manager

3.  Using the Sample Programs

4.  Writing a Client Program

Client API Overview

Sequence of a Client Application

Opening and Closing a Client Connection

About Namespaces

Opening a Client Connection

Closing a Client Connection

Performing Basic Client Operations

Creating an Instance

Deleting an Instance

Getting and Setting Instances

Getting and Setting Properties

Enumerating Objects

Enumerating Objects

Creating Associations

About the Association Methods

Passing a Class to the Association Methods

Passing Instances to the Association Methods

Using Optional Arguments With the Association Methods

Calling Methods

Retrieving Class Definitions

Handling Exceptions

Creating a Namespace

Deleting a Namespace

Creating a Base Class

Deleting a Class

Setting Access Control

Solaris_UserAcl Class

To Set Access Control for a User

Solaris_NamespaceAcl Class

To Set Access Control for a Namespace

Working With Qualifiers and Qualifier Types

Getting and Setting CIM Qualifiers

Batching Client Requests

Handling CIM Events

About Indications

About Subscriptions

To Create a Subscription

Adding a CIM Listener

Creating an Event Filter

To Create an Event Filter

Creating an Event Handler

Binding an Event Filter to an Event Handler

Reading and Writing Log Messages

About Log Files

5.  Writing WBEM Queries

6.  Writing a Provider Program

7.  Creating JavaBeans Components Using the MOF Compiler

8.  Administering Security

9.  Troubleshooting

A.  Solaris Schema


Opening and Closing a Client Connection

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.

About Namespaces

When an application connects to the CIMOM, the application must also connect to a namespace, where all subsequent operations occur. A namespace is a directory-like structure that contains classes, instances, and qualifier types. The names of all objects within a namespace must be unique. When you install the Solaris WBEM SDK, four namespaces are created:

Opening a Client Connection

To open a client connection, you use the CIMClient class to connect to the CIM Object Manager. The CIMClient class takes four arguments:

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 namespace. The application creates a UserPrincipal object for the root account, which has read and write access to all CIM objects in the default namespace.


   /* Create a namespace object initialized with two null strings
   that specify the default host (the local host) and the default 
   namespace (root\cimv2).*/
   CIMNameSpace cns = new CIMNameSpace("", "");

   UserPrincipal up = new UserPrincipal("root");
   PasswordCredential pc = new PasswordCredential("root-password"); 
   /* Connect to the namespace 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, namespace, user name, and password credential in order to create a connection to the CIMOM.

    /* Create a namespace object initialized with A 
    (name of namespace) 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);

Closing a Client Connection

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(); ...