ca.tnt.ldaputils
Interface ILdapEntry

Package class diagram package ILdapEntry
All Known Subinterfaces:
ILdapBusiness, ILdapGroup, ILdapInetOrgPerson, ILdapOrganization, ILdapPerson
All Known Implementing Classes:
LdapBusiness, LdapEntry, LDAPEntryImpl, LdapGroup, LdapOrganization

public interface ILdapEntry

Implements LDAP objects.

Author:
Trenton D. Adams

Field Summary
static int ADD_ATTRIBUTE
          Used in setting attributes.
static int REMOVE_ATTRIBUTE
          Used in setting attributes.
static int REPLACE_ATTRIBUTE
          Used in setting attributes.
 
Method Summary
 ILdapEntry convertInstance(int type)
           
 List getAttributeValues(String attribute)
           
 Attributes getBindAttributes()
           
 String getCn()
           
 String getCN()
           
 String getDescription()
           
 LdapName getDn()
           
 List getObjectClasses()
          Get's the types of objects this is.
 String getStringValue(String attribute)
           
 void modifyAttribute(int operation, String attribute, Object value)
          Sets the given attribute right now, and does not delay.
 void modifyBatchAttribute(int operation, String attribute, Object value)
          Please note, the preferred method is to call setXXXX() where XXXX is the attribute name, followed by save().
 void modifyBatchAttributes()
          Runs the batch modifications requested through the modifyBatchAttribute(int, String, Object)
 void save()
          Because LDAP operations are expensive, we have a save method.
 void setCn(String cn)
           
 void setDn(LdapName dn)
           
 

Field Detail

ADD_ATTRIBUTE

static final int ADD_ATTRIBUTE
Used in setting attributes. MEANING - add the attribute value, whether other values for it exist or not.

The values of this constant is 0

DirContext.ADD_ATTRIBUTE

See Also:
Constant Field Values

REPLACE_ATTRIBUTE

static final int REPLACE_ATTRIBUTE
Used in setting attributes. MEANING - modify the existing attribute. 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 1

DirContext.REPLACE_ATTRIBUTE

See Also:
Constant Field Values

REMOVE_ATTRIBUTE

static final int REMOVE_ATTRIBUTE
Used in setting attributes. MEANING - delete the existing attribute. Delete corresponding value, if *value* is specified. Delete all if *value* is null. This may be used in a batch. If you call the modifyBatchAttribute(int, java.lang.String, java.lang.Object) several times with REMOVE_ATTRIBUTE, then all the attributes with the specified values will be removed.

The value of this constant is 2

DirContext.REMOVE_ATTRIBUTE

See Also:
Constant Field Values
Method Detail

getObjectClasses

List getObjectClasses()
Get's the types of objects this is.

Returns:
a list of Strings representing the object class names

getCN

String getCN()
Returns:
the common name attribute.

getDn

LdapName getDn()
Returns:
the distinquished name of the object. ie, fully qualified path in LDAP tree.

getDescription

String getDescription()
Returns:
the description attribute.

convertInstance

ILdapEntry convertInstance(int type)
                           throws NamingException
Parameters:
type - the object type to convert to
Returns:
the new converted object
Throws:
NamingException - if any conversion problems occur.

getAttributeValues

List getAttributeValues(String attribute)

getStringValue

String getStringValue(String attribute)

modifyAttribute

void modifyAttribute(int operation,
                     String attribute,
                     Object value)
Sets the given attribute right now, and does not delay. This should only be used in the case where there is only one value for the attribute. If there are multiple values, then the modifyBatchAttribute is the one that really needs to be called. If you call this with REPLACE_ATTRIBUTE for instance, and there was multiple entries in LDAP, then the existing entries will be replaced with this one value and only this one value. In addition, if you want to modify multiple attributes at a time, then you should not call this, you should use modifyBatchAttribute().

Parameters:
operation - on of ADD_ATTRIBUTE, REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
attribute - the name of the attribute
value - the value of the attribute
See Also:
ADD_ATTRIBUTE, REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE

modifyBatchAttribute

void modifyBatchAttribute(int operation,
                          String attribute,
                          Object value)
Please note, the preferred method is to call setXXXX() where XXXX is the attribute name, followed by save().

This sets a batch attribute. This means that it will be added to a queue for changing LDAP. You can modify the same attribute multiple times, assuming LDAP supports multivalued attributes for that attribute. You are then required to call modifyBatchAttributes(), which will actually do the operations requested.

You should call this one or more times per attribute, followed by modifyBatchAttributes().

Each time you call this method, for the same attribute, you should specify the same operation, otherwise you will get an IllegalArgumentException, with an appropriate error message.

Parameters:
operation - one of ADD_ATTRIBUTE, REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE
attribute - the name of the attribute
value - the value of the attribute
See Also:
ADD_ATTRIBUTE, REPLACE_ATTRIBUTE, REMOVE_ATTRIBUTE

modifyBatchAttributes

void modifyBatchAttributes()
Runs the batch modifications requested through the modifyBatchAttribute(int, String, Object)


save

void save()
Because LDAP operations are expensive, we have a save method. Saves any changes made by setXXXX() methods, where XXXX is an attribute name. Also an alias for modifyBatchAttributes(), but will do nothing unless modifyBatchAtribute() has been called


getBindAttributes

Attributes getBindAttributes()

setDn

void setDn(LdapName dn)

getCn

String getCn()

setCn

void setCn(String cn)