The directory service interface, containing methods for examining and updating attributes associated with objects, and for searching the directory.

Names

Each name passed as an argument to a DirContext method is relative to that context. The empty name is used to name the context itself. The name parameter may never be null.

Most of the methods have overloaded versions with one taking a Name parameter and one taking a String. These overloaded versions are equivalent in that if the Name and String parameters are just different representations of the same name, then the overloaded versions of the same methods behave the same. In the method descriptions below, only one version is documented. The second version instead has a link to the first: the same documentation applies to both.

See Context for a discussion on the interpretation of the name argument to the Context methods. These same rules apply to the name argument to the DirContext methods.

Attribute Models

There are two basic models of what attributes should be associated with. First, attributes may be directly associated with a DirContext object. In this model, an attribute operation on the named object is roughly equivalent to a lookup on the name (which returns the DirContext object), followed by the attribute operation invoked on the DirContext object in which the caller supplies an empty name. The attributes can be viewed as being stored along with the object (note that this does not imply that the implementation must do so).

The second model is that attributes are associated with a name (typically an atomic name) in a DirContext. In this model, an attribute operation on the named object is roughly equivalent to a lookup on the name of the parent DirContext of the named object, followed by the attribute operation invoked on the parent in which the caller supplies the terminal atomic name. The attributes can be viewed as being stored in the parent DirContext (again, this does not imply that the implementation must do so). Objects that are not DirContexts can have attributes, as long as their parents are DirContexts.

JNDI support both of these models. It is up to the individual service providers to decide where to "store" attributes. JNDI clients are safest when they do not make assumptions about whether an object's attributes are stored as part of the object, or stored within the parent object and associated with the object's name.

Attribute Type Names

In the getAttributes() and search() methods, you can supply the attributes to return by supplying a list of attribute names (strings). The attributes that you get back might not have the same names as the attribute names you have specified. This is because some directories support features that cause them to return other attributes. Such features include attribute subclassing, attribute name synonyms, and attribute language codes.

In attribute subclassing, attributes are defined in a class hierarchy. In some directories, for example, the "name" attribute might be the superclass of all name-related attributes, including "commonName" and "surName". Asking for the "name" attribute might return both the "commonName" and "surName" attributes.

With attribute type synonyms, a directory can assign multiple names to the same attribute. For example, "cn" and "commonName" might both refer to the same attribute. Asking for "cn" might return the "commonName" attribute.

Some directories support the language codes for attributes. Asking such a directory for the "description" attribute, for example, might return all of the following attributes:

Operational Attributes

Some directories have the notion of "operational attributes" which are attributes associated with a directory object for administrative purposes. An example of operational attributes is the access control list for an object.

In the getAttributes() and search() methods, you can specify that all attributes associated with the requested objects be returned by supply null as the list of attributes to return. The attributes returned do not include operational attributes. In order to retrieve operational attributes, you must name them explicitly.

Named Context

There are certain methods in which the name must resolve to a context (for example, when searching a single level context). The documentation of such methods use the term named context to describe their name parameter. For these methods, if the named object is not a DirContext, NotContextException is thrown. Aside from these methods, there is no requirement that the named object be a DirContext.

Parameters

An Attributes, SearchControls, or array object passed as a parameter to any method will not be modified by the service provider. The service provider may keep a reference to it for the duration of the operation, including any enumeration of the method's results and the processing of any referrals generated. The caller should not modify the object during this time. An Attributes object returned by any method is owned by the caller. The caller may subsequently modify it; the service provider will not.

Exceptions

All the methods in this interface can throw a NamingException or any of its subclasses. See NamingException and their subclasses for details on each exception.

@author
Rosanna Lee
@author
Scott Seligman
@author
R. Vasudevan
@version
1.11 04/05/05
@since
1.3
This constant specifies to add an attribute with the specified values.

If attribute does not exist, create the attribute. The resulting attribute has a union of the specified value set and the prior value set. Adding an attribute with no value will throw InvalidAttributeValueException if the attribute must have at least one value. For a single-valued attribute where that attribute already exists, throws AttributeInUseException. If attempting to add more than one value to a single-valued attribute, throws InvalidAttributeValueException.

The value of this constant is 1.

Constant that holds the name of the environment property for specifying an applet for the initial context constructor to use when searching for other properties. The value of this property is the java.applet.Applet instance that is being executed. This property may be specified in the environment parameter passed to the initial context constructor. When this property is set, each property that the initial context constructor looks for in the system properties is first looked for in the applet's parameter list. If this property is unspecified, the initial context constructor will search for properties only in the environment parameter passed to it, the system properties, and application resource files.

The value of this constant is "java.naming.applet".

Constant that holds the name of the environment property for specifying the authoritativeness of the service requested. If the value of the property is the string "true", it means that the access is to the most authoritative source (i.e. bypass any cache or replicas). If the value is anything else, the source need not be (but may be) authoritative. If unspecified, the value defaults to "false".

The value of this constant is "java.naming.authoritative".

Constant that holds the name of the environment property for specifying the batch size to use when returning data via the service's protocol. This is a hint to the provider to return the results of operations in batches of the specified size, so the provider can optimize its performance and usage of resources. The value of the property is the string representation of an integer. If unspecified, the batch size is determined by the service provider.

The value of this constant is "java.naming.batchsize".

Constant that holds the name of the environment property for specifying the DNS host and domain names to use for the JNDI URL context (for example, "dns://somehost/wiz.com"). This property may be specified in the environment, an applet parameter, a system property, or a resource file. If it is not specified in any of these sources and the program attempts to use a JNDI URL containing a DNS name, a ConfigurationException will be thrown.

The value of this constant is "java.naming.dns.url".

Constant that holds the name of the environment property for specifying the initial context factory to use. The value of the property should be the fully qualified class name of the factory class that will create an initial context. This property may be specified in the environment parameter passed to the initial context constructor, an applet parameter, a system property, or an application resource file. If it is not specified in any of these sources, NoInitialContextException is thrown when an initial context is required to complete an operation.

The value of this constant is "java.naming.factory.initial".

Constant that holds the name of the environment property for specifying the preferred language to use with the service. The value of the property is a colon-separated list of language tags as defined in RFC 1766. If this property is unspecified, the language preference is determined by the service provider.

The value of this constant is "java.naming.language".

Constant that holds the name of the environment property for specifying the list of object factories to use. The value of the property should be a colon-separated list of the fully qualified class names of factory classes that will create an object given information about the object. This property may be specified in the environment, an applet parameter, a system property, or one or more resource files.

The value of this constant is "java.naming.factory.object".

Constant that holds the name of the environment property for specifying configuration information for the service provider to use. The value of the property should contain a URL string (e.g. "ldap://somehost:389"). This property may be specified in the environment, an applet parameter, a system property, or a resource file. If it is not specified in any of these sources, the default configuration is determined by the service provider.

The value of this constant is "java.naming.provider.url".

Constant that holds the name of the environment property for specifying how referrals encountered by the service provider are to be processed. The value of the property is one of the following strings:
"follow"
follow referrals automatically
"ignore"
ignore referrals
"throw"
throw ReferralException when a referral is encountered.
If this property is not specified, the default is determined by the provider.

The value of this constant is "java.naming.referral".

This constant specifies to delete the specified attribute values from the attribute.

The resulting attribute has the set difference of its prior value set and the specified value set. If no values are specified, deletes the entire attribute. If the attribute does not exist, or if some or all members of the specified value set do not exist, this absence may be ignored and the operation succeeds, or a NamingException may be thrown to indicate the absence. Removal of the last value will remove the attribute if the attribute is required to have at least one value.

The value of this constant is 3.

This constant specifies to replace an attribute with specified values.

If attribute already exists, replaces all existing values with new specified values. If the attribute does not exist, creates it. If no value is specified, deletes all the values of the attribute. Removal of the last value will remove the attribute if the attribute is required to have at least one value. If attempting to add more than one value to a single-valued attribute, throws InvalidAttributeValueException.

The value of this constant is 2.

Constant that holds the name of the environment property for specifying the security level to use. Its value is one of the following strings: "none", "simple", "strong". If this property is unspecified, the behaviour is determined by the service provider.

The value of this constant is "java.naming.security.authentication".

Constant that holds the name of the environment property for specifying the credentials of the principal for authenticating the caller to the service. The value of the property depends on the authentication scheme. For example, it could be a hashed password, clear-text password, key, certificate, and so on. If this property is unspecified, the behaviour is determined by the service provider.

The value of this constant is "java.naming.security.credentials".

Constant that holds the name of the environment property for specifying the identity of the principal for authenticating the caller to the service. The format of the principal depends on the authentication scheme. If this property is unspecified, the behaviour is determined by the service provider.

The value of this constant is "java.naming.security.principal".

Constant that holds the name of the environment property for specifying the security protocol to use. Its value is a string determined by the service provider (e.g. "ssl"). If this property is unspecified, the behaviour is determined by the service provider.

The value of this constant is "java.naming.security.protocol".

Constant that holds the name of the environment property for specifying the list of state factories to use. The value of the property should be a colon-separated list of the fully qualified class names of state factory classes that will be used to get an object's state given the object itself. This property may be specified in the environment, an applet parameter, a system property, or one or more resource files.

The value of this constant is "java.naming.factory.state".

Constant that holds the name of the environment property for specifying the list of package prefixes to use when loading in URL context factories. The value of the property should be a colon-separated list of package prefixes for the class name of the factory class that will create a URL context factory. This property may be specified in the environment, an applet parameter, a system property, or one or more resource files. The prefix com.sun.jndi.url is always appended to the possibly empty list of package prefixes.

The value of this constant is "java.naming.factory.url.pkgs".

Adds a new environment property to the environment of this context. If the property already exists, its value is overwritten. See class description for more details on environment properties.
Parameters
propName the name of the environment property to add; may not be null
propVal the value of the property to add; may not be null
Return
the previous value of the property, or null if the property was not in the environment before
Throws
NamingExceptionif a naming exception is encountered
Binds a name to an object. All intermediate contexts and the target context (that named by all but terminal atomic component of the name) must already exist.
Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
Throws
NameAlreadyBoundExceptionif name is already bound
javax.naming.directory.InvalidAttributesException if object did not supply all mandatory attributes
NamingExceptionif a naming exception is encountered
Binds a name to an object, along with associated attributes. If attrs is null, the resulting binding will have the attributes associated with obj if obj is a DirContext, and no attributes otherwise. If attrs is non-null, the resulting binding will have attrs as its attributes; any attributes associated with obj are ignored.
Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
attrs the attributes to associate with the binding
Throws
NameAlreadyBoundExceptionif name is already bound
InvalidAttributesExceptionif some "mandatory" attributes of the binding are not supplied
NamingExceptionif a naming exception is encountered
Binds a name to an object. See for details.
Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
Throws
NameAlreadyBoundExceptionif name is already bound
javax.naming.directory.InvalidAttributesException if object did not supply all mandatory attributes
NamingExceptionif a naming exception is encountered
Binds a name to an object, along with associated attributes. See for details.
Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
attrs the attributes to associate with the binding
Throws
NameAlreadyBoundExceptionif name is already bound
InvalidAttributesExceptionif some "mandatory" attributes of the binding are not supplied
NamingExceptionif a naming exception is encountered
Closes this context. This method releases this context's resources immediately, instead of waiting for them to be released automatically by the garbage collector.

This method is idempotent: invoking it on a context that has already been closed has no effect. Invoking any other method on a closed context is not allowed, and results in undefined behaviour.

Throws
NamingExceptionif a naming exception is encountered
Composes the name of this context with a name relative to this context. Given a name (name) relative to this context, and the name (prefix) of this context relative to one of its ancestors, this method returns the composition of the two names using the syntax appropriate for the naming system(s) involved. That is, if name names an object relative to this context, the result is the name of the same object, but relative to the ancestor context. None of the names may be null.

For example, if this context is named "wiz.com" relative to the initial context, then

	composeName("east", "wiz.com")	
might return "east.wiz.com". If instead this context is named "org/research", then
	composeName("user/jane", "org/research")	
might return "org/research/user/jane" while
	composeName("user/jane", "research")	
returns "research/user/jane".
Parameters
name a name relative to this context
prefix the name of this context relative to one of its ancestors
Return
the composition of prefix and name
Throws
NamingExceptionif a naming exception is encountered
Composes the name of this context with a name relative to this context. See for details.
Parameters
name a name relative to this context
prefix the name of this context relative to one of its ancestors
Return
the composition of prefix and name
Throws
NamingExceptionif a naming exception is encountered
Creates and binds a new context. Creates a new context with the given name and binds it in the target context (that named by all but terminal atomic component of the name). All intermediate contexts and the target context must already exist.
Parameters
name the name of the context to create; may not be empty
Return
the newly created context
Throws
NameAlreadyBoundExceptionif name is already bound
javax.naming.directory.InvalidAttributesException if creation of the subcontext requires specification of mandatory attributes
NamingExceptionif a naming exception is encountered
Creates and binds a new context, along with associated attributes. This method creates a new subcontext with the given name, binds it in the target context (that named by all but terminal atomic component of the name), and associates the supplied attributes with the newly created object. All intermediate and target contexts must already exist. If attrs is null, this method is equivalent to Context.createSubcontext().
Parameters
name the name of the context to create; may not be empty
attrs the attributes to associate with the newly created context
Return
the newly created context
Throws
NameAlreadyBoundExceptionif the name is already bound
InvalidAttributesExceptionif attrs does not contain all the mandatory attributes required for creation
NamingExceptionif a naming exception is encountered
Creates and binds a new context. See for details.
Parameters
name the name of the context to create; may not be empty
Return
the newly created context
Throws
NameAlreadyBoundExceptionif name is already bound
javax.naming.directory.InvalidAttributesException if creation of the subcontext requires specification of mandatory attributes
NamingExceptionif a naming exception is encountered
Creates and binds a new context, along with associated attributes. See for details.
Parameters
name the name of the context to create; may not be empty
attrs the attributes to associate with the newly created context
Return
the newly created context
Throws
NameAlreadyBoundExceptionif the name is already bound
InvalidAttributesExceptionif attrs does not contain all the mandatory attributes required for creation
NamingExceptionif a naming exception is encountered
Destroys the named context and removes it from the namespace. Any attributes associated with the name are also removed. Intermediate contexts are not destroyed.

This method is idempotent. It succeeds even if the terminal atomic name is not bound in the target context, but throws NameNotFoundException if any of the intermediate contexts do not exist.

In a federated naming system, a context from one naming system may be bound to a name in another. One can subsequently look up and perform operations on the foreign context using a composite name. However, an attempt destroy the context using this composite name will fail with NotContextException, because the foreign context is not a "subcontext" of the context in which it is bound. Instead, use unbind() to remove the binding of the foreign context. Destroying the foreign context requires that the destroySubcontext() be performed on a context from the foreign context's "native" naming system.

Parameters
name the name of the context to be destroyed; may not be empty
Throws
NameNotFoundExceptionif an intermediate context does not exist
NotContextExceptionif the name is bound but does not name a context, or does not name a context of the appropriate type
ContextNotEmptyExceptionif the named context is not empty
NamingExceptionif a naming exception is encountered
Destroys the named context and removes it from the namespace. See for details.
Parameters
name the name of the context to be destroyed; may not be empty
Throws
NameNotFoundExceptionif an intermediate context does not exist
NotContextExceptionif the name is bound but does not name a context, or does not name a context of the appropriate type
ContextNotEmptyExceptionif the named context is not empty
NamingExceptionif a naming exception is encountered
Retrieves all of the attributes associated with a named object. See the class description regarding attribute models, attribute type names, and operational attributes.
Parameters
name the name of the object from which to retrieve attributes
Return
the set of attributes associated with name. Returns an empty attribute set if name has no attributes; never null.
Throws
NamingExceptionif a naming exception is encountered
Retrieves selected attributes associated with a named object. See the class description regarding attribute models, attribute type names, and operational attributes.

If the object does not have an attribute specified, the directory will ignore the nonexistent attribute and return those requested attributes that the object does have.

A directory might return more attributes than was requested (see Attribute Type Names in the class description), but is not allowed to return arbitrary, unrelated attributes.

See also Operational Attributes in the class description.

Parameters
name the name of the object from which to retrieve attributes
attrIds the identifiers of the attributes to retrieve. null indicates that all attributes should be retrieved; an empty array indicates that none should be retrieved.
Return
the requested attributes; never null
Throws
NamingExceptionif a naming exception is encountered
Retrieves all of the attributes associated with a named object. See for details.
Parameters
name the name of the object from which to retrieve attributes
Return
the set of attributes associated with name
Throws
NamingExceptionif a naming exception is encountered
Retrieves selected attributes associated with a named object. See for details.
Parameters
name The name of the object from which to retrieve attributes
attrIds the identifiers of the attributes to retrieve. null indicates that all attributes should be retrieved; an empty array indicates that none should be retrieved.
Return
the requested attributes; never null
Throws
NamingExceptionif a naming exception is encountered
Retrieves the environment in effect for this context. See class description for more details on environment properties.

The caller should not make any changes to the object returned: their effect on the context is undefined. The environment of this context may be changed using addToEnvironment() and removeFromEnvironment().

Return
the environment of this context; never null
Throws
NamingExceptionif a naming exception is encountered
Retrieves the full name of this context within its own namespace.

Many naming services have a notion of a "full name" for objects in their respective namespaces. For example, an LDAP entry has a distinguished name, and a DNS record has a fully qualified name. This method allows the client application to retrieve this name. The string returned by this method is not a JNDI composite name and should not be passed directly to context methods. In naming systems for which the notion of full name does not make sense, OperationNotSupportedException is thrown.

Return
this context's name in its own namespace; never null
Throws
OperationNotSupportedExceptionif the naming system does not have the notion of a full name
NamingExceptionif a naming exception is encountered
@since
1.3
Retrieves the parser associated with the named context. In a federation of namespaces, different naming systems will parse names differently. This method allows an application to get a parser for parsing names into their atomic components using the naming convention of a particular naming system. Within any single naming system, NameParser objects returned by this method must be equal (using the equals() test).
Parameters
name the name of the context from which to get the parser
Return
a name parser that can parse compound names into their atomic components
Throws
NamingExceptionif a naming exception is encountered
Retrieves the parser associated with the named context. See for details.
Parameters
name the name of the context from which to get the parser
Return
a name parser that can parse compound names into their atomic components
Throws
NamingExceptionif a naming exception is encountered
Retrieves the schema associated with the named object. The schema describes rules regarding the structure of the namespace and the attributes stored within it. The schema specifies what types of objects can be added to the directory and where they can be added; what mandatory and optional attributes an object can have. The range of support for schemas is directory-specific.

This method returns the root of the schema information tree that is applicable to the named object. Several named objects (or even an entire directory) might share the same schema.

Issues such as structure and contents of the schema tree, permission to modify to the contents of the schema tree, and the effect of such modifications on the directory are dependent on the underlying directory.

Parameters
name the name of the object whose schema is to be retrieved
Return
the schema associated with the context; never null
Throws
OperationNotSupportedExceptionif schema not supported
NamingExceptionif a naming exception is encountered
Retrieves the schema associated with the named object. See for details.
Parameters
name the name of the object whose schema is to be retrieved
Return
the schema associated with the context; never null
Throws
OperationNotSupportedExceptionif schema not supported
NamingExceptionif a naming exception is encountered
Retrieves a context containing the schema objects of the named object's class definitions.

One category of information found in directory schemas is class definitions. An "object class" definition specifies the object's type and what attributes (mandatory and optional) the object must/can have. Note that the term "object class" being referred to here is in the directory sense rather than in the Java sense. For example, if the named object is a directory object of "Person" class, getSchemaClassDefinition() would return a DirContext representing the (directory's) object class definition of "Person".

The information that can be retrieved from an object class definition is directory-dependent.

Prior to JNDI 1.2, this method returned a single schema object representing the class definition of the named object. Since JNDI 1.2, this method returns a DirContext containing all of the named object's class definitions.

Parameters
name the name of the object whose object class definition is to be retrieved
Return
the DirContext containing the named object's class definitions; never null
Throws
OperationNotSupportedExceptionif schema not supported
NamingExceptionif a naming exception is encountered
Retrieves a context containing the schema objects of the named object's class definitions. See for details.
Parameters
name the name of the object whose object class definition is to be retrieved
Return
the DirContext containing the named object's class definitions; never null
Throws
OperationNotSupportedExceptionif schema not supported
NamingExceptionif a naming exception is encountered
Enumerates the names bound in the named context, along with the class names of objects bound to them. The contents of any subcontexts are not included.

If a binding is added to or removed from this context, its effect on an enumeration previously returned is undefined.

Parameters
name the name of the context to list
Return
an enumeration of the names and class names of the bindings in this context. Each element of the enumeration is of type NameClassPair.
Throws
NamingExceptionif a naming exception is encountered
Enumerates the names bound in the named context, along with the class names of objects bound to them. See for details.
Parameters
name the name of the context to list
Return
an enumeration of the names and class names of the bindings in this context. Each element of the enumeration is of type NameClassPair.
Throws
NamingExceptionif a naming exception is encountered
Enumerates the names bound in the named context, along with the objects bound to them. The contents of any subcontexts are not included.

If a binding is added to or removed from this context, its effect on an enumeration previously returned is undefined.

Parameters
name the name of the context to list
Return
an enumeration of the bindings in this context. Each element of the enumeration is of type Binding.
Throws
NamingExceptionif a naming exception is encountered
Enumerates the names bound in the named context, along with the objects bound to them. See for details.
Parameters
name the name of the context to list
Return
an enumeration of the bindings in this context. Each element of the enumeration is of type Binding.
Throws
NamingExceptionif a naming exception is encountered
Retrieves the named object. If name is empty, returns a new instance of this context (which represents the same naming context as this context, but its environment may be modified independently and it may be accessed concurrently).
Parameters
name the name of the object to look up
Return
the object bound to name
Throws
NamingExceptionif a naming exception is encountered
Retrieves the named object. See for details.
Parameters
name the name of the object to look up
Return
the object bound to name
Throws
NamingExceptionif a naming exception is encountered
Retrieves the named object, following links except for the terminal atomic component of the name. If the object bound to name is not a link, returns the object itself.
Parameters
name the name of the object to look up
Return
the object bound to name, not following the terminal link (if any).
Throws
NamingExceptionif a naming exception is encountered
Retrieves the named object, following links except for the terminal atomic component of the name. See for details.
Parameters
name the name of the object to look up
Return
the object bound to name, not following the terminal link (if any)
Throws
NamingExceptionif a naming exception is encountered
Modifies the attributes associated with a named object. The order of the modifications is not specified. Where possible, the modifications are performed atomically.
Parameters
name the name of the object whose attributes will be updated
mod_op the modification operation, one of: ADD_ATTRIBUTE, REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE.
attrs the attributes to be used for the modification; may not be null
Throws
AttributeModificationExceptionif the modification cannot be completed successfully
NamingExceptionif a naming exception is encountered
Modifies the attributes associated with a named object using an ordered list of modifications. The modifications are performed in the order specified. Each modification specifies a modification operation code and an attribute on which to operate. Where possible, the modifications are performed atomically.
Parameters
name the name of the object whose attributes will be updated
mods an ordered sequence of modifications to be performed; may not be null
Throws
AttributeModificationExceptionif the modifications cannot be completed successfully
NamingExceptionif a naming exception is encountered
Modifies the attributes associated with a named object. See for details.
Parameters
name the name of the object whose attributes will be updated
mod_op the modification operation, one of: ADD_ATTRIBUTE, REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE.
attrs the attributes to be used for the modification; map not be null
Throws
AttributeModificationExceptionif the modification cannot be completed successfully
NamingExceptionif a naming exception is encountered
Modifies the attributes associated with a named object using an ordered list of modifications. See for details.
Parameters
name the name of the object whose attributes will be updated
mods an ordered sequence of modifications to be performed; may not be null
Throws
AttributeModificationExceptionif the modifications cannot be completed successfully
NamingExceptionif a naming exception is encountered
Binds a name to an object, overwriting any existing binding. All intermediate contexts and the target context (that named by all but terminal atomic component of the name) must already exist.

If the object is a DirContext, any existing attributes associated with the name are replaced with those of the object. Otherwise, any existing attributes associated with the name remain unchanged.

Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
Throws
javax.naming.directory.InvalidAttributesException if object did not supply all mandatory attributes
NamingExceptionif a naming exception is encountered
Binds a name to an object, along with associated attributes, overwriting any existing binding. If attrs is null and obj is a DirContext, the attributes from obj are used. If attrs is null and obj is not a DirContext, any existing attributes associated with the object already bound in the directory remain unchanged. If attrs is non-null, any existing attributes associated with the object already bound in the directory are removed and attrs is associated with the named object. If obj is a DirContext and attrs is non-null, the attributes of obj are ignored.
Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
attrs the attributes to associate with the binding
Throws
InvalidAttributesExceptionif some "mandatory" attributes of the binding are not supplied
NamingExceptionif a naming exception is encountered
Binds a name to an object, overwriting any existing binding. See for details.
Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
Throws
javax.naming.directory.InvalidAttributesException if object did not supply all mandatory attributes
NamingExceptionif a naming exception is encountered
Binds a name to an object, along with associated attributes, overwriting any existing binding. See for details.
Parameters
name the name to bind; may not be empty
obj the object to bind; possibly null
attrs the attributes to associate with the binding
Throws
InvalidAttributesExceptionif some "mandatory" attributes of the binding are not supplied
NamingExceptionif a naming exception is encountered
Removes an environment property from the environment of this context. See class description for more details on environment properties.
Parameters
propName the name of the environment property to remove; may not be null
Return
the previous value of the property, or null if the property was not in the environment
Throws
NamingExceptionif a naming exception is encountered
Binds a new name to the object bound to an old name, and unbinds the old name. Both names are relative to this context. Any attributes associated with the old name become associated with the new name. Intermediate contexts of the old name are not changed.
Parameters
oldName the name of the existing binding; may not be empty
newName the name of the new binding; may not be empty
Throws
NameAlreadyBoundExceptionif newName is already bound
NamingExceptionif a naming exception is encountered
Binds a new name to the object bound to an old name, and unbinds the old name. See for details.
Parameters
oldName the name of the existing binding; may not be empty
newName the name of the new binding; may not be empty
Throws
NameAlreadyBoundExceptionif newName is already bound
NamingExceptionif a naming exception is encountered
Searches in a single context for objects that contain a specified set of attributes. This method returns all the attributes of such objects. It is equivalent to supplying null as the atributesToReturn parameter to the method search(Name, Attributes, String[]).
See for a full description.
Parameters
name the name of the context to search
matchingAttributes the attributes to search for
Return
an enumeration of SearchResult objects
Throws
NamingExceptionif a naming exception is encountered
Searches in a single context for objects that contain a specified set of attributes, and retrieves selected attributes. The search is performed using the default SearchControls settings.

For an object to be selected, each attribute in matchingAttributes must match some attribute of the object. If matchingAttributes is empty or null, all objects in the target context are returned.

An attribute A1 in matchingAttributes is considered to match an attribute A2 of an object if A1 and A2 have the same identifier, and each value of A1 is equal to some value of A2. This implies that the order of values is not significant, and that A2 may contain "extra" values not found in A1 without affecting the comparison. It also implies that if A1 has no values, then testing for a match is equivalent to testing for the presence of an attribute A2 with the same identifier.

The precise definition of "equality" used in comparing attribute values is defined by the underlying directory service. It might use the Object.equals method, for example, or might use a schema to specify a different equality operation. For matching based on operations other than equality (such as substring comparison) use the version of the search method that takes a filter argument.

When changes are made to this DirContext, the effect on enumerations returned by prior calls to this method is undefined.

If the object does not have the attribute specified, the directory will ignore the nonexistent attribute and return the requested attributes that the object does have.

A directory might return more attributes than was requested (see Attribute Type Names in the class description), but is not allowed to return arbitrary, unrelated attributes.

See also Operational Attributes in the class description.

Parameters
name the name of the context to search
matchingAttributes the attributes to search for. If empty or null, all objects in the target context are returned.
attributesToReturn the attributes to return. null indicates that all attributes are to be returned; an empty array indicates that none are to be returned.
Return
a non-null enumeration of SearchResult objects. Each SearchResult contains the attributes identified by attributesToReturn and the name of the corresponding object, named relative to the context named by name.
Throws
NamingExceptionif a naming exception is encountered
Searches in the named context or object for entries that satisfy the given search filter. Performs the search as specified by the search controls.

The interpretation of filterExpr is based on RFC 2254. It may additionally contain variables of the form {i} -- where i is an integer -- that refer to objects in the filterArgs array. The interpretation of filterExpr is otherwise identical to that of the filter parameter of the method search(Name, String, SearchControls).

When a variable {i} appears in a search filter, it indicates that the filter argument filterArgs[i] is to be used in that place. Such variables may be used wherever an attr, value, or matchingrule production appears in the filter grammar of RFC 2254, section 4. When a string-valued filter argument is substituted for a variable, the filter is interpreted as if the string were given in place of the variable, with any characters having special significance within filters (such as '*') having been escaped according to the rules of RFC 2254.

For directories that do not use a string representation for some or all of their attributes, the filter argument corresponding to an attribute value may be of a type other than String. Directories that support unstructured binary-valued attributes, for example, should accept byte arrays as filter arguments. The interpretation (if any) of filter arguments of any other type is determined by the service provider for that directory, which maps the filter operations onto operations with corresponding semantics in the underlying directory.

This method returns an enumeration of the results. Each element in the enumeration contains the name of the object and other information about the object (see SearchResult). The name is either relative to the target context of the search (which is named by the name parameter), or it is a URL string. If the target context is included in the enumeration (as is possible when cons specifies a search scope of SearchControls.OBJECT_SCOPE or SearchControls.SUBSTREE_SCOPE), its name is the empty string.

The SearchResult may also contain attributes of the matching object if the cons argument specifies that attributes be returned.

If the object does not have a requested attribute, that nonexistent attribute will be ignored. Those requested attributes that the object does have will be returned.

A directory might return more attributes than were requested (see Attribute Type Names in the class description) but is not allowed to return arbitrary, unrelated attributes.

If a search filter with invalid variable substitutions is provided to this method, the result is undefined. When changes are made to this DirContext, the effect on enumerations returned by prior calls to this method is undefined.

See also Operational Attributes in the class description.

Parameters
name the name of the context or object to search
filterExpr the filter expression to use for the search. The expression may contain variables of the form "{i}" where i is a nonnegative integer. May not be null.
filterArgs the array of arguments to substitute for the variables in filterExpr. The value of filterArgs[i] will replace each occurrence of "{i}". If null, equivalent to an empty array.
cons the search controls that control the search. If null, the default search controls are used (equivalent to (new SearchControls())).
Return
an enumeration of SearchResults of the objects that satisfy the filter; never null
Throws
ArrayIndexOutOfBoundsExceptionif filterExpr contains {i} expressions where i is outside the bounds of the array filterArgs
InvalidSearchControlsExceptionif cons contains invalid settings
InvalidSearchFilterExceptionif filterExpr with filterArgs represents an invalid search filter
NamingExceptionif a naming exception is encountered
Searches in the named context or object for entries that satisfy the given search filter. Performs the search as specified by the search controls.

The format and interpretation of filter follows RFC 2254 with the following interpretations for attr and value mentioned in the RFC.

attr is the attribute's identifier.

value is the string representation the attribute's value. The translation of this string representation into the attribute's value is directory-specific.

For the assertion "someCount=127", for example, attr is "someCount" and value is "127". The provider determines, based on the attribute ID ("someCount") (and possibly its schema), that the attribute's value is an integer. It then parses the string "127" appropriately.

Any non-ASCII characters in the filter string should be represented by the appropriate Java (Unicode) characters, and not encoded as UTF-8 octets. Alternately, the "backslash-hexcode" notation described in RFC 2254 may be used.

If the directory does not support a string representation of some or all of its attributes, the form of search that accepts filter arguments in the form of Objects can be used instead. The service provider for such a directory would then translate the filter arguments to its service-specific representation for filter evaluation. See search(Name, String, Object[], SearchControls).

RFC 2254 defines certain operators for the filter, including substring matches, equality, approximate match, greater than, less than. These operators are mapped to operators with corresponding semantics in the underlying directory. For example, for the equals operator, suppose the directory has a matching rule defining "equality" of the attributes in the filter. This rule would be used for checking equality of the attributes specified in the filter with the attributes of objects in the directory. Similarly, if the directory has a matching rule for ordering, this rule would be used for making "greater than" and "less than" comparisons.

Not all of the operators defined in RFC 2254 are applicable to all attributes. When an operator is not applicable, the exception InvalidSearchFilterException is thrown.

The result is returned in an enumeration of SearchResults. Each SearchResult contains the name of the object and other information about the object (see SearchResult). The name is either relative to the target context of the search (which is named by the name parameter), or it is a URL string. If the target context is included in the enumeration (as is possible when cons specifies a search scope of SearchControls.OBJECT_SCOPE or SearchControls.SUBSTREE_SCOPE), its name is the empty string. The SearchResult may also contain attributes of the matching object if the cons argument specified that attributes be returned.

If the object does not have a requested attribute, that nonexistent attribute will be ignored. Those requested attributes that the object does have will be returned.

A directory might return more attributes than were requested (see Attribute Type Names in the class description) but is not allowed to return arbitrary, unrelated attributes.

See also Operational Attributes in the class description.

Parameters
name the name of the context or object to search
filter the filter expression to use for the search; may not be null
cons the search controls that control the search. If null, the default search controls are used (equivalent to (new SearchControls())).
Return
an enumeration of SearchResults of the objects that satisfy the filter; never null
Throws
InvalidSearchFilterExceptionif the search filter specified is not supported or understood by the underlying directory
InvalidSearchControlsExceptionif the search controls contain invalid settings
NamingExceptionif a naming exception is encountered
Searches in a single context for objects that contain a specified set of attributes. See for details.
Parameters
name the name of the context to search
matchingAttributes the attributes to search for
Return
an enumeration of SearchResult objects
Throws
NamingExceptionif a naming exception is encountered
Searches in a single context for objects that contain a specified set of attributes, and retrieves selected attributes. See for details.
Parameters
name the name of the context to search
matchingAttributes the attributes to search for
attributesToReturn the attributes to return
Return
a non-null enumeration of SearchResult objects
Throws
NamingExceptionif a naming exception is encountered
Searches in the named context or object for entries that satisfy the given search filter. Performs the search as specified by the search controls. See for details.
Parameters
name the name of the context or object to search
filterExpr the filter expression to use for the search. The expression may contain variables of the form "{i}" where i is a nonnegative integer. May not be null.
filterArgs the array of arguments to substitute for the variables in filterExpr. The value of filterArgs[i] will replace each occurrence of "{i}". If null, equivalent to an empty array.
cons the search controls that control the search. If null, the default search controls are used (equivalent to (new SearchControls())).
Return
an enumeration of SearchResults of the objects that satisfy the filter; never null
Throws
ArrayIndexOutOfBoundsExceptionif filterExpr contains {i} expressions where i is outside the bounds of the array filterArgs
InvalidSearchControlsExceptionif cons contains invalid settings
InvalidSearchFilterExceptionif filterExpr with filterArgs represents an invalid search filter
NamingExceptionif a naming exception is encountered
Searches in the named context or object for entries that satisfy the given search filter. Performs the search as specified by the search controls. See for details.
Parameters
name the name of the context or object to search
filter the filter expression to use for the search; may not be null
cons the search controls that control the search. If null, the default search controls are used (equivalent to (new SearchControls())).
Return
an enumeration of SearchResults for the objects that satisfy the filter.
Throws
InvalidSearchFilterExceptionif the search filter specified is not supported or understood by the underlying directory
InvalidSearchControlsExceptionif the search controls contain invalid settings
NamingExceptionif a naming exception is encountered
Unbinds the named object. Removes the terminal atomic name in name from the target context--that named by all but the terminal atomic part of name.

This method is idempotent. It succeeds even if the terminal atomic name is not bound in the target context, but throws NameNotFoundException if any of the intermediate contexts do not exist.

Any attributes associated with the name are removed. Intermediate contexts are not changed.

Parameters
name the name to unbind; may not be empty
Throws
NameNotFoundExceptionif an intermediate context does not exist
NamingExceptionif a naming exception is encountered
Unbinds the named object. See for details.
Parameters
name the name to unbind; may not be empty
Throws
NameNotFoundExceptionif an intermediate context does not exist
NamingExceptionif a naming exception is encountered