1.11 Attribute Concepts

An attribute is comprised of an attribute ID (the name of the attribute) and one or more values. Each value is an object of class java.lang.Object, meaning that a value can be a String, Integer, and so forth. In JNDI, an attribute is an atomic property of a DirContext represented in the interface javax.naming.directory.Attribute and the class javax.naming.directory.BasicAttribute.

An attribute set is a collection of attributes of a DirContext, and in JNDI is represented in the javax.naming.directory.Attributes interface. Individual attributes are accessed by using the javax.naming.NamingEnumeration interface, which allows you to traverse the attribute set using the next( ) method that returns individual Attribute objects.

Dynamic attributes are attributes that can optionally be associated with an object. For example, if you call getAttributes( ) at a context for an NDS object, you will get an AttributeSet that contains only the attributes that have been defined (assigned a value) for the object. If a new attribute is added to the object and you again retrieve the object’s attributes, you will get a set of attributes containing the newly added attribute.

The NDS schema specifies attributes as mandatory or optional. Mandatory attributes must be defined and given a value before the object can be created. For example, the NDS user class has an attribute called Surname. Whenever you create an NDS user object, the Surname attribute must be given a value.

Optional attributes may be added to the object, and may or may not be assigned a value, after its creation. For example, the NDS user class has an attribute called FAX. It is not a requirement that the FAX attribute be defined when the object is created.