I have written an interceptor that makes use of a custom AttributeType
and it works fine when I manually import that AttributeType via an ldif
import. I want to make my interceptor more robust by automatically
registering the AttributeType on startup if it is not yet defined. I
tried the code below but I get a
"javax.naming.ServiceUnavailableException: Directory service is not
started." error when I add the entry. What is the correct way to add a
new AttributeType within an interceptor?
-Alan
[called from the interceptor's init() method]
private void registerEntryDNAttributeType(DirectoryService
directoryService)
{
try
{
LdapDN entryDN = new
LdapDN("m-oid=2.16.840.1.113730.3.1.602,ou=attributeTypes,cn=other,ou=sc
hema");
ServerEntry serverEntry = directoryService.newEntry(entryDN);
serverEntry.add("m-name", ENTRY_DN_NAME);
serverEntry.add("m-description", "Sun ONE defined virtual
attribute type");
serverEntry.add("m-equality", "2.5.13.1");
serverEntry.add("m-syntax", "1.3.6.1.4.1.1466.115.121.1.12");
serverEntry.add("m-singleValue", "true");
serverEntry.add("m-usage", "DSA_OPERATION");
directoryService.getAdminSession().add(serverEntry);
}
catch (Exception e)
{
logger.error("Failed adding entryDN attribute type", e);
}
}