UnboundID: The entry contains attribute ‘XXXX’ which is not defined in the schema

PROBLEM

Let’s assume we have the following LDIF file containing custom attribute(s), such as managedBy:-

dn: dc=MyShittyCode
objectClass: top
objectClass: domain
dc: MyShittyCode

dn: CN=ShittyEmployee,DC=MyShittyCode
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
sn: ShittyEmployee
managedBy: CN=ShittyBoss,DC=MyShittyCode

When running the code on UnboundID’s In-Memory Directory Server, the following exception is thrown:-

LDAPException(resultCode=65 (object class violation), 
errorMessage='Unable to add entry 'CN=ShittyEmployee,DC=MyShittyCode' 
because it violates the provided schema:  The entry contains attribute 
managedBy which is not defined in the schema.')
	at com.unboundid.ldap.listener.InMemoryRequestHandler.addEntry(InMemoryRequestHandler.java:4055)
	at com.unboundid.ldap.listener.InMemoryRequestHandler.importFromLDIF(InMemoryRequestHandler.java:3876)
	at com.unboundid.ldap.listener.InMemoryDirectoryServer.importFromLDIF(InMemoryDirectoryServer.java:1226)
	at com.unboundid.ldap.listener.InMemoryDirectoryServer.importFromLDIF(InMemoryDirectoryServer.java:1198)

SOLUTION

The problem is caused by the fact that the default schema does not match Microsoft’s Active Directory schema. Hence, attribute(s), such as managedBy, would cause an error.

While we can set a modified schema, which is very convoluted, the easiest solution is to completely disable the schema:-

def config = new InMemoryDirectoryServerConfig(base)
config.setListenerConfigs(new InMemoryListenerConfig("myListener", null, port, null, null, null))
config.setSchema(null)

def server = new InMemoryDirectoryServer(config)
server.startListening()
server.importFromLDIF(true, "target/test-classes/unboundid-test-data.ldif")
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s