Collapse All Expand All

.NET Framework Class Library
LookupContextFactory Class See Also

[TIBCO.EMS .NET client library 5.1 documentation]

Returns the initial context used to search for administered objects

Namespace: TIBCO.EMS
Assembly: TIBCO.EMS (in TIBCO.EMS.dll)

# Syntax

    public ILookupContext CreateContext(
    	string name,
    	Hashtable props
    )

    Public Function CreateContext ( _
    	name As String, _
    	props As Hashtable _
    ) As ILookupContext

    public:
    ILookupContext^ CreateContext(
    	String^ name,
    	Hashtable^ props
    )

#### Parameters

name
  Type: System..::.String
  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
  Type: System.Collections..::.Hashtable
  Hash table of properties.

#### Return Value

An object that implements ILookupContext interface

# Remarks

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.

# Examples

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

| Copy Code
--- | ---
                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:

| Copy Code
--- | ---
                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.

| Copy Code
--- | ---
                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());

# Exceptions

Exception | Condition
--- | ---
System..::.ArgumentException | If name is null or invalid name (anything other than tibjmsnaming or ldap) is specified

# See Also

LookupContextFactory Class
TIBCO.EMS Namespace