Previous | Next | Trail Map | Beyond the Basics | Environment Properties

Overview

The JNDI is a generic interface. To access any naming/directory service, you must specify the service provider to use. Specifying the service provider to use is but one piece of configuration information. Depending on the naming/directory service and the service provider, you might need to specify other configuration information. For example, you might need to tell the service provider which server to talk to. The way you specify configuration information in the JNDI is to use environment properties. Although there are many environment properties described in this section, in general, you only need to specify a few properties.

There are different types of environment properties, categorized based on their scope and applicability:

Standard JNDI Environment Properties

The JNDI defines environment properties that are standard across all service providers. Not all standard environment properties are applicable to all service providers. But when a service provider does use one of these properties, it must interpret the property according to the definition specified by the JNDI.

These properties have the prefix "java.naming.". The Context(in the API reference documentation) and LdapContext(in the API reference documentation) interfaces declare constants for these properties. Here is a list of the standard JNDI environment properties.
Property Name Description
java.naming.applet
( Context.APPLET(in the API reference documentation))
An instance of java.applet.Applet. The applet parameters of this applet instance is used to obtain certain environment properties. See the next section for details.
Default: none
java.naming.authoritative
( Context.AUTHORITATIVE(in the API reference documentation))
A string (true or false) that specifies the authoritative of the service requested. If you set this property to true, you are asking the service provider to use the most authoritative source for the service (such as a master server). Otherwise the source need not be (but can be) authoritative.
Default: false
java.naming.batchsize
( Context.BATCHSIZE(in the API reference documentation))
The string representation of an integer that specifies the preferred batch size to use when returning data via the service's protocol. See the Search (in the Tips for LDAP Users trail) lesson for details and an example.
Default: Provider's default.
Example: 10
java.naming.dns.url
( Context.DNS_URL(in the API reference documentation))
A URL string that specifies the DNS host and domain names to use for the the "jndi" URL context implementation.
Default: none
Example: dns://dnsserver/wiz.com
java.naming.factory.control
( LdapContext.CONTROL_FACTORIES(in the API reference documentation))
Colon-separated list of class names of control factories. Each class must implement the ControlFactory(in the API reference documentation) interface. This property is used by ControlFactory.getControlInstance() (in the API reference documentation) , which in turn is used by service providers. See the Controls and Extensions (in the Java Objects and the Directory trail) lesson for details.
Default: the empty list.
Example: com.wiz.jndi.ldap.ControlFactory:vendorX.ldap.VendorXControlFactory
java.naming.factory.initial
( Context.INITIAL_CONTEXT_FACTORY(in the API reference documentation))
Class name of the initial context factory. Class must implement the InitialContextFactory(in the API reference documentation)interface. This class is instanted by the InitialContext constructor(in the API reference documentation) . Unless you pass only URL names to the InitialContext(in the API reference documentation) methods, you must set this property.
Default: none.
Example: com.sun.jndi.ldap.LdapCtxFactory
java.naming.factory.object
( Context.OBJECT_FACTORIES(in the API reference documentation))
Colon-separated list of class names of object factories. Each class must implement the ObjectFactory(in the API reference documentation) or DirObjectFactory(in the API reference documentation) interface. This property is used by NamingManager.getObjectInstance() (in the API reference documentation) and DirectoryManager.getObjectInstance() (in the API reference documentation) , which in turn are used by service providers. See the Java Objects and the Directory (in the Java Objects and the Directory trail) trail for details.
Default: the empty list.
Example: com.wiz.jndi.ldap.AttrsToRemote:com.wiz.jndi.ldap.AttrsToCorba
java.naming.factory.state
( Context.STATE_FACTORIES(in the API reference documentation))
Colon-separated list of class names of state factories. Each class must implement the StateFactory(in the API reference documentation) or DirStateFactory(in the API reference documentation) interface. This property is used by NamingManager.getStateToBind() (in the API reference documentation) and DirectoryManager.getStateToBind() (in the API reference documentation) , which in turn are used by service providers. See the Java Objects and the Directory (in the Java Objects and the Directory trail) trail for details.
Default: the empty list.
Example: com.wiz.jndi.ldap.RemoteToAttrs:com.wiz.jndi.ldap.CorbaToAttrs
java.naming.factory.url.pkgs
( Context.URL_PKG_PREFIXES(in the API reference documentation))
Colon-separated list of package prefixes or URL context factories. The prefix is composed with the URL scheme id and a suffix to construct the class name as follows:
prefix.schemeId.schemeIdURLContextFactory
For example, suppose the prefix is vendorZ.jndi and the URL scheme id is ldap, the complete class name is vendorZ.jndi.ldap.ldapURLContextFactory. Each class whose name is constructed in this manner must implement the ObjectFactory(in the API reference documentation) or DirObjectFactory(in the API reference documentation) interface and follow the rules for processing URL names. The package prefix com.sun.jndi.url is always appended to the end of the list specified by this property. This property is used when a URL name is passed to the InitialContext(in the API reference documentation) methods. See the URL (in the Beyond the Basics trail) lesson for more information.
Default: the empty list.
Example: com.wiz.jndi.url:vendorZ.jndi
java.naming.language
( Context.LANGUAGE(in the API reference documentation))
A string specifying the preferred language to use with this service. The values of this property are defined by RFC 1766.
Default: Provider's default.
Example: en-US
java.naming.provider.url
( Context.PROVIDER_URL(in the API reference documentation))
A URL string for configuring the service provider specified by the java.naming.factory.initial property.
Default: Provider's default.
Example: ldap://localhost:389/o=JNDITutorial
java.naming.referral
( Context.REFERRAL(in the API reference documentation))
A string specifying how the service provider should handle referrals; one of throw, ignore, or follow. See the Referrals (in the Tips for LDAP Users trail) lesson for details and examples.
Default: Provider's default.
Example: throw
java.naming.security.authentication
( Context.SECURITY_AUTHENTICATION(in the API reference documentation))
A string specifying the type of authentication to use; one of none, simple, strong, or a provider-specific string. See the Security (in the Tips for LDAP Users trail) lesson for details and examples.
Default: Provider's default.
Example: simple
java.naming.security.credentials
( Context.SECURITY_CREDENTIALS(in the API reference documentation))
An object specifying the credentials of the entity performing the authentication. Its type is determined by the service provider. See the Security (in the Tips for LDAP Users trail) lesson for details and examples.
Default: Provider's default.
Example: A char[] containing "secret".
java.naming.security.principal
( Context.SECURITY_PRINCIPAL(in the API reference documentation))
A string specifying the identity of the entity performing the authentication. See the Security (in the Tips for LDAP Users trail) lesson for details and examples.
Default: Provider's default.
Example: cn=Directory Manager, o=JNDITutorial
java.naming.security.protocol
( Context.SECURITY_PROTOCOL(in the API reference documentation))
A string specifying the security protocol to use. See the Security (in the Tips for LDAP Users trail) lesson for details and an example.
Default: Provider's default.
Example: ssl

Service-specific Environment Properties

Service-specific environment properties are common across all service providers that implement a particular service or protocol. For example, there might be several different service providers that implement the LDAP. These providers would use LDAP-specific environment properties.

Service-specific properties have the prefix "java.naming.service.". For example, the LDAP-specific properties would have the prefix "java.naming.ldap.", while the CORBA-specific properties would have the prefix "java.naming.corba.". Note that these are JNDI-related environment properties used by the JNDI service providers. A service or subsystem such as the CORBA or the RMI might define other properties unrelated to the JNDI. See the Miscellaneous (in the Tips for LDAP Users trail) lesson for examples of LDAP-specific environment properties.

Feature-specific Environment Properties

Feature-specific environment properties are common across all service providers that implement a particular feature. For example, the LDAP service provider and a VendorX service provider might both use the SASL for authentication. These providers would then use SASL-specific environment properties when configuring that feature.

Feature-specific properties have the prefix "java.naming.feature.". For example, the SASL-specific properties would have the prefix "java.naming.security.sasl.". Note that these are JNDI-related environment properties used by the JNDI service providers. A feature or subsystem such as the SASL might define other properties unrelated to the JNDI. See the Security (in the Tips for LDAP Users trail) lesson for some examples of SASL-specific properties.

Provider-specific Environment Properties

Provider-specific environment properties are properties used by only one service provider. For example, Sun's LDAP service provider has a property for turning on tracing. (See example in the Frequently Asked Questions (in the Tips for LDAP Users trail) lesson.) Provider-specific properties should have a prefix that reflects their uniqueness. A common practice is to use the package name of the service provider as the prefix. For example, The Sun LDAP provider's trace property has the name "com.sun.jndi.ldap.trace.ber".


Previous | Next | Trail Map | Beyond the Basics | Environment Properties