Just adding a little bit more of a scenario into the mix. The scenario is that
I'll create a context L0, and it will have several children that are directory
entries, like L1A, L1B, L1C etc. Earlier Stefan gave me this code for
iterating through the children of a context and getting the context associated
with each child:
NamingEnumeration enm = ctx.listBindings("");
while (enm.hasMore()) {
Binding b = (Binding) enm.next();
if (b.getObject() instanceof Context) {
Context child = (Context) b.getObject();
}
}
So ctx in this case is the L0 context. So at this point I am unable to get the
child contexts associated with the bindings that represent the children of the
L0 context. I can look them up using lookup() which will return a directory
context instance.
Anyone know of any other way to get a list of the child contexts?
Thanks,
- Ole
Emmanuel Lecharny wrote:
Well, it's not really clear, but I think that a Binding, in a LDAP
context, is just an Attributes, not a Context.
It's a little bit different than a directory and a file. A LDAP entry
is an entry and can be the father of others entries. This duality does
not exactly applies to other kind of directories...
Alex, thougths ?
On 6/11/07, Ole Ersoy <[EMAIL PROTECTED]> wrote:
Hey Guys,
I'm trying to obtain a context from a binding. I first create a L0
context, and then an L1 context that's a sub context of the L0
context. I'm wondering whether the asserts below should pass (They do
pass)?
NamingEnumeration<Binding> childEntryContexts =
directoryContextL0.listBindings("");
assertTrue( childEntryContexts.hasMore() );
Binding binding = ( Binding ) childEntryContexts.next();
assertEquals( "cn=L1,cn=L0,ou=test", binding.getName() );
assertNull( binding.getObject() );
JGuru says this:
listBindings() attempts to return an enumeration of the Binding's of
all of the objects in the current context. I.e., it's a listing of all
of the objects in the current context with the object's name, its
class name, and a reference to the object itself.
It seems like the reference to the L1 object (Context) is missing in
this case, although we can see that it's there because binding returns
its name. Thoughts?
Thanks,
- Ole