TIBCO EMS .NET API 8.5 TIBCO EMS .NET API 8.5

- Main Page
- Related Pages
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes | List of all members
TIBCO.EMS.LookupContextFactory Class Reference

Create ILookupContext objects More...

Inheritance diagram for TIBCO.EMS.LookupContextFactory:

## Public Member Functions
| LookupContextFactory ()
| Default constructor to create a context factory More...
virtual ILookupContext | CreateContext (String name, Hashtable props)
| Returns the initial context used to search for administered objects More...

## Public Attributes
const String | LDAP_CONTEXT = "ldap"
| Public const string to create a ldap context to lookup administered object in an ldap server. More...
const String | TIBJMS_NAMING_CONTEXT = "tibjmsnaming"
| Public const string to create a tibjmsnaming context to lookup administered object inside the tibjmsnaming server. More...

## Detailed Description

Create ILookupContext objects

To lookup administered objects (ConnectionFactories, Topics and Queues) in either a third-party LDAP naming server or the TIBCO EMS Naming server, clients create an instance of the LookupContextFactory and invoke the CreateContext method to get an ILookupContext object.

Users can create an instance of the LookupContextFactory and the invoke the CreateContext method to get a LDAP_CONTEXT or TIBJMS_NAMING_CONTEXT object.

Example for creating a context for looking up objects in the built in naming/directory server

Hashtable env = new Hashtable();
env.Add(LookupContext.PROVIDER_URL, "tibjmsnaming://localhost:7222");
env.Add(LookupContext.SECURITY_PRINCIPAL", "myUserName");
env.Add(LookupContext.SECURITY_CREDENTIALS", "myPassword");
try {
LookupContextFactory factory = new LookupContextFactory();
ILookupContext searcher = factory.CreateContext(LookupContextFactory.TIBJMS_NAMING_CONTEXT, env);
TIBCO.EMS.Queue queue = (TIBCO.EMS.Queue)searcher.Lookup("theQueueName");
...
} catch (NamingException) {
...
}

This example shows how to lookup an object in the LDAP server by getting an LdapLookupContext from the LookupConextFactory.

Hashtable table = new Hashtable();
table.Add(LdapLookupConsts.LDAP_SERVER_URL, "10.105.185.30:10389");
table.Add(LdapLookupConsts.LDAP_BASE_DN, "ou=People,dc=emsproject");
table.Add(LdapLookupConsts.LDAP_PRINCIPAL, "cn=Manager");
table.Add(LdapLookupConsts.LDAP_CREDENTIAL, "password");
table.Add(LdapLookupConsts.LDAP_CONN_TYPE, "ldap");
try {
LookupContextFactory factory = new LookupContextFactory();
ILookupContext searcher = factory.CreateContext(LookupContextFactory.LDAP_CONTEXT, env);
TIBCO.EMS.Queue queue = (TIBCO.EMS.Queue)searcher.Lookup("theQueueName");
...
} catch (NamingException) {
...
}

## Constructor & Destructor Documentation

TIBCO.EMS.LookupContextFactory.LookupContextFactory | ( |  | ) |
| inline

Default constructor to create a context factory

## Member Function Documentation

virtual ILookupContext TIBCO.EMS.LookupContextFactory.CreateContext | ( | String | name,
|  | Hashtable | props
| ) |  |
| inline virtual

Returns the initial context used to search for administered objects

This method returns an ILookupContext object that is the initial context used to look up administered object in the EMS server or an LDAP server. The currently supported contexts are tibjmsnaming and ldap.

Before calling CreateContext, first create a hash table of properties and their values.

This example demonstrates how to create an initial context for looking up a queue object in the EMS naming server:

Hashtable env = new Hashtable();
env.Add(LookupContext.PROVIDER_URL, "tibjmsnaming://localhost:7222");
env.Add(LookupContext.SECURITY_PRINCIPAL", "myUserName");
env.Add(LookupContext.SECURITY_CREDENTIALS", "myPassword");
LookupContextFactory factory = new LookupContextFactory();
ILookupContext searcher = factory.CreateContext(
LookupContextFactory.TIBJMS_NAMING_CONTEXT, env);
TIBCO.EMS.Queue queue = (TIBCO.EMS.Queue)searcher.Lookup("theQueueName");

This example shows how to look up a connection factory, named `testConnFact`, in a third-party LDAP server located at the URL: 10.105.185.30:10389:

Hashtable env = new Hashtable();
table.Add(LdapLookupConsts.LDAP_SERVER_URL, "10.105.185.30:10389");
table.Add(LdapLookupConsts.LDAP_BASE_DN,"ou=People,dc=nmunjal1");
table.Add(LdapLookupConsts.LDAP_PRINCIPAL, "cn=Manager");
table.Add(LdapLookupConsts.LDAP_CREDENTIAL, "password");
table.Add(LdapLookupConsts.LDAP_CONN_TYPE, "ldap");
LookupContextFactory contextFactory = new LookupContextFactory();
ILookupContext searcher = contextFactory.CreateContext(
LookupContextFactory.LDAP_CONTEXT, env);
ConnectionFactory cf = (ConnectionFactory)searcher.Lookup("cn=testConnFact");

This example shows how to look up a connection factory object in the LDAP server via SSL.

Hashtable props = new Hashtable();
props.Add(LdapLookupConsts.LDAP_SERVER_URL", "adc1.na.tibco.com:10636");
props.Add(LdapLookupConsts.LDAP_BASE_DN", "ou=People,dc=test-user");
props.Add(LdapLookupConsts.LDAP_PRINCIPAL", "cn=Manager");
props.Add(LdapLookupConsts.LDAP_CREDENTIAL", "password");
props.Add(LdapLookupConsts.LDAP_SEARCH_SCOPE, "subtree");
props.Add(LdapLookupConsts.LDAP_CONN_TYPE, "ldaps");
props.Add(LdapLookupConsts.LDAP_CERT_NAME, "certName");
props.Add(LdapLookupConsts.LDAP_CERT_STORE_NAME, "My");
props.Add(LdapLookupConsts.LDAP_CERT_STORE_LOCATION, "currentuser");
LdapLookupSSLParams sslparams = new LdapLookupSSLParams();
sslparams.SetSSLQueryClientCertificateCallback(QueryClientCertificateCallback);
sslparams.SetSSLVerifyServerCertificateCallback(VerifyServerCertificateCallback);
props.Add(LdapLookupConsts.LDAP_SSL_PARAMS, sslparams);
LookupContextFactory contextFactory = new LookupContextFactory();
ILookupContext searcher = contextFactory.CreateContext(
LookupContextFactory.LDAP_CONTEXT,
props);
ConnectionFactory cf = searcher.Lookup("cn=testConnFact");
Console.WriteLine("cf = " + cf.ToString());

Parameters

  name | Can be either: TIBJMS_NAMING_CONTEXT to create an initial context in the EMS server. LDAP_CONTEXT to create an initial context in an LDAP server.
  props | Hash table of properties.

Returns
  An object that implements ILookupContext interface

Exceptions

  ArgumentException | If name is `null` or invalid name (anything other than tibjmsnaming or ldap) is specified

Reimplemented in TIBCO.EMS.UFO.LookupContextFactory.

## Member Data Documentation

const String TIBCO.EMS.LookupContextFactory.LDAP_CONTEXT = "ldap"

Public const string to create a ldap context to lookup administered object in an ldap server.

const String TIBCO.EMS.LookupContextFactory.TIBJMS_NAMING_CONTEXT = "tibjmsnaming"

Public const string to create a tibjmsnaming context to lookup administered object inside the tibjmsnaming server.