Kiran Ayyagari <[email protected]> writes: > On Thu, Aug 22, 2013 at 12:07 AM, Gerald Turner <[email protected]> wrote: >> Kiran Ayyagari <[email protected]> writes: >> > On Wed, Aug 21, 2013 at 5:37 AM, Gerald Turner <[email protected]> wrote: >> >> Emmanuel Lécharny <[email protected]> writes: >> >> > Le 7/26/13 12:01 AM, Richard Sand a écrit : >> >> >> 5) What needs to happen to have the results of calls to >> >> >> LdapConnection.search(..) return entries for which >> >> >> isSchemaAware is true? >> >> > The LdapConnection must be schema aware itself. >> >> > >> >> > For that to happen, you just have to call the loadSchema() >> >> > method : >> >> > >> >> > LdapConnection connection = new LdapNetworkConnection( "localhost", >> >> > 389); >> >> > connection.loadSchema(); >> >> > >> >> > Here, we will load the default schemas. >> >> > >> >> > You can use some specific schema by using : >> >> > >> >> > connection.loadSchema(); >> >> > connection.addSchema( "MySchema.schema" ); >> >> > >> >> > where the "MySchema.schema" is a schema in OpenLDAP format. >> >> > >> >> > You can also use a SchemaLoader, but this get a bit too complex >> >> > atm (and sadly, the associated method is not yet in the >> >> > LdapConnection interface) >> >> >> >> I've tried: >> >> >> >> con.loadSchema() >> >> ((LdapNetworkConnection) con).loadSchema(new DefaultSchemaLoader(…)) >> >> ((LdapNetworkConnection) con).loadSchema(new SingleLdifSchemaLoader(…)) >> >> ((LdapNetworkConnection) con).loadSchema(new JarLdifSchemaLoader(…)) >> >> >> >> without much success until finally trying: >> > >> > what was the error encountered while using above schema loaders? >> > (are using a then inside a web application?) >> >> The errors were really just learning exercises ;-) >> >> Mostly from JUnit in Eclipse, but eventually in a web application on >> JBoss 7. It is odd that JarLdifSchemaLoader couldn't find the schema >> directory in api-ldap-schema-data-1.0.0-M20.jar, I'll investigate >> this further. > > this is most likely due to an issue with classloaders
Yep, I now have JarLdifSchemaLoader loading the schema just fine.
However now I believe I may be onto a real bug again.
I'm loading the schema with code like this:
con.loadSchema(new JarLdifSchemaLoader());
con.addSchema("custom.schema");
Later an exception is thrown while I'm handling some search results.
The entry in question looks like:
dn: cn=ICRCSSTAccess,ou=Roles,o=jaas,dc=xoint,dc=net
objectClass: groupOfNames
cn: ICRCSSTAccess
member: uid=gturner,ou=people,dc=xoint,dc=net
member:
uuid=98bb35ee-9ff3-444f-9925-7fe762810d50,o=Asus,ou=customers,dc=xoint,dc=net
The code where the exception is thrown looks like this:
Attribute memberAttribute = entry.get("member");
if (memberAttribute != null)
for (Iterator<Value<?>> iterator = memberAttribute.iterator();
iterator.hasNext();) {
@SuppressWarnings("unchecked")
Value<String> value = (Value<String>) iterator.next();
String member = value.getValue();
Dn memberDn = new Dn(context.getSchemaManager(), member);
members.add(memberDn);
}
It is the Dn instantiation that throws the following stacktrace:
org.apache.directory.api.ldap.model.exception.LdapInvalidDnException:
ERR_04188 The type cannot be empty or null
at org.apache.directory.api.ldap.model.name.Dn.atavOidToName(Dn.java:1106)
at org.apache.directory.api.ldap.model.name.Dn.rdnOidToName(Dn.java:1143)
at org.apache.directory.api.ldap.model.name.Rdn.apply(Rdn.java:454)
at org.apache.directory.api.ldap.model.name.Dn.apply(Dn.java:1202)
at org.apache.directory.api.ldap.model.name.Dn.apply(Dn.java:1281)
at org.apache.directory.api.ldap.model.name.Dn.<init>(Dn.java:287)
at net.xoint.usermanager.model.Role.<init>(Role.java:45)
at net.xoint.usermanager.model.LDAPLoader.loadRoles(LDAPLoader.java:75)
at net.xoint.usermanager.model.LDAPLoader.load(LDAPLoader.java:52)
at net.xoint.usermanager.UserManagerTest.test2(UserManagerTest.java:134)
Caused by:
org.apache.directory.api.ldap.model.exception.LdapInvalidDnException: ERR_04188
The type cannot be empty or null
at org.apache.directory.api.ldap.model.name.Ava.apply(Ava.java:476)
at org.apache.directory.api.ldap.model.name.Dn.atavOidToName(Dn.java:1100)
... 36 more
Caused by:
org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException:
ERR_04269 ATTRIBUTE_TYPE for OID 1.3.6.1.4.1.38541.2.1.3 does not exist!
at
org.apache.directory.api.ldap.model.schema.registries.DefaultAttributeTypeRegistry.lookup(DefaultAttributeTypeRegistry.java:293)
at
org.apache.directory.api.ldap.model.schema.registries.DefaultAttributeTypeRegistry.lookup(DefaultAttributeTypeRegistry.java:47)
at
org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager.lookupAttributeTypeRegistry(DefaultSchemaManager.java:1604)
at org.apache.directory.api.ldap.model.name.Ava.apply(Ava.java:470)
... 37 more
Caused by: org.apache.directory.api.ldap.model.exception.LdapException:
ERR_04269 ATTRIBUTE_TYPE for OID 1.3.6.1.4.1.38541.2.1.3 does not exist!
at
org.apache.directory.api.ldap.model.schema.registries.DefaultSchemaObjectRegistry.lookup(DefaultSchemaObjectRegistry.java:176)
at
org.apache.directory.api.ldap.model.schema.registries.DefaultAttributeTypeRegistry.lookup(DefaultAttributeTypeRegistry.java:289)
... 40 more
OID 1.3.6.1.4.1.38541.2.1.3 is the uuid attribute that is part of a
member DN. "custom.schema" defines it as follows:
attributetype ( 1.3.6.1.4.1.38541.2.1.3
NAME 'uuid'
DESC 'The customer UUID'
EQUALITY UUIDMatch
SYNTAX 1.3.6.1.1.16.1
SINGLE-VALUE )
While scrutinizing the source, looking for why this attribute wouldn't
be found in the DefaultSchemaObjectRegistry#byName Map for the
AttributeTypeRegistry, I'm beginning to suspect that somewhere around
where LdapNetworkConnection#addSchema is calling
AttributeTypeRegistry#addMappingFor, it hasn't quite finished the job,
perhaps something like calling AttributeTypeRegistry#register (which
seems to be the only method that put's into the byName Map).
Note that I had been using a custom hacked up local copy of the schema
folder with my custom jammed in, this *was* working, however I'd much
rather use the stock schema folder (JarLdifSchemaLoader) and one file
containing my custom schema.
--
Gerald Turner Email: [email protected] JID: [email protected]
GPG: 0xFA8CD6D5 21D9 B2E8 7FE7 F19E 5F7D 4D0C 3FA0 810F FA8C D6D5
pgpjQPSI77oBx.pgp
Description: PGP signature
