What's wrong with the getAttributes(String, String[]) method of DirContext
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Robert_Wingerden
Posted On:   Tuesday, May 29, 2001 08:08 AM

Hi, I'll pose my question by providing a piece of source code. Source code: // Setting the environment; env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://10.10.10.20/"); env.put(Context.SECURITY_PRINCIPAL, "cn=admin, o=lag"); env.put(Context.SECURITY_CREDENTIALS, "xyz"); // instantiating a context ctx = new InitialDirContext(env); // looking up an object dtx=(DirContext) ctx.lookup("cn=cnbndd3h, ou=company, ou=fundel, ou=webapps, ou=sassenheim, o=lag");    More>>

Hi,



I'll pose my question by providing a piece of source code.



Source code:

// Setting the environment;

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL, "ldap://10.10.10.20/");

env.put(Context.SECURITY_PRINCIPAL, "cn=admin, o=lag");

env.put(Context.SECURITY_CREDENTIALS, "xyz");



// instantiating a context

ctx = new InitialDirContext(env);





// looking up an object

dtx=(DirContext) ctx.lookup("cn=cnbndd3h, ou=company, ou=fundel, ou=webapps, ou=sassenheim, o=lag");





AND now it comes:

attributes = dtx.getAttributes("", new String[] { "X", "Y", "Z"}); //doesn't work

System.out.println(attributes.get("X"));

System.out.println(attributes.get("Y"));

System.out.println(attributes.get("Z"));



... produces

X-values

null

Z-values





And if my code looks like... (remark the getAttributes() method

without providing a subset (String[])

as argument)

attributes = dtx.getAttributes("");

System.out.println(attributes.get("X"));

System.out.println(attributes.get("Y"));

System.out.println(attributes.get("Z"));



... the outcome is okay.

X-values

Y-values

Z-values





Can somebody tell me WHAT'S WRONG???



grtz Robert

   <<Less

Re: What's wrong with the getAttributes(String, String[]) method of DirContext

Posted By:   Anonymous  
Posted On:   Tuesday, May 29, 2001 12:25 PM

My opinion is that your problem it's just a syntax problem. I think that the syntax you've used is not correct. Can you please try this?



attributes = dtx.getAttributes("", {"X", "Y", "Z"});



You do not need to include the new String[] because it's implicit in this case.

Regards.
About | Sitemap | Contact