dcsimg
Getting LDAP: error code 32 - No Such Object
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pramod_Mirji
Posted On:   Sunday, February 3, 2002 10:20 PM

Hi All, I am using iPlanet Directory Server 5.1, I just installed the diectory server and I am trying to get attributes for user, My code looks like this, Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389"); try { // Create the initial directory context DirContext ctx = new InitialDirContext(env); // Ask for all attributes of the object Attributes attrs = ctx.getAttributes("cn=Pramod Mirji,ou=people"); // Find the surname ("sn") and print i   More>>

Hi All,

I am using iPlanet Directory Server 5.1, I just installed the diectory server and I am trying to get attributes for user, My code looks like this,



Hashtable env = new Hashtable(11);

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

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


try {


// Create the initial directory context

DirContext ctx = new InitialDirContext(env);


// Ask for all attributes of the object

Attributes attrs = ctx.getAttributes("cn=Pramod Mirji,ou=people");


// Find the surname ("sn") and print it

System.out.println("sn: " + attrs.get("sn").get());


// Close the context when we're done

ctx.close();

} catch (NamingException e) {

System.err.println("Problem getting attribute: " + e);

}



when I execute this program I am getting following exception,



problem getting attribute: javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]
remaining name 'cn=Pramod Mirji,ou=people'





can anybody help me ........
or give me an example code which does similar thing....

Thanks,
Pramod    <<Less

Re: Getting LDAP: error code 32 - No Such Object

Posted By:   Nicholas_Whitehead  
Posted On:   Thursday, April 11, 2002 03:37 AM

Pramod;

I think there are oneissues that may be preventing you from finding the object.


There is no Organization in your lookup. There is usually a root DN called something like "o=pramod.com". You have two ways you can specify this:

  • Include it in the PROVIDER_URL as follows:

    env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=pranod.com");

  • Specify it in the lookup:

    Attributes attrs = ctx.getAttributes("cn=Pramod Mirji,ou=people, o=pranod.com");

That should fix the problem.

//Nicholas

Re: Getting LDAP: error code 32 - No Such Object

Posted By:   Jayaram_S  
Posted On:   Sunday, February 3, 2002 11:24 PM


Space () is a LDAP special character according to DN syntax.
Please escape the space by a baclslash and try.



The code will look like this.


DirContext ctx = new InitialDirContext(env);
// Ask for all attributes of the object
Attributes attrs = ctx.getAttributes("cn=Pramod\\ Mirji,ou=people");


A space has to be escaped by a . But itsef is a special char in JNDI. So it has to be escaped by another . Further
is a special char in JAVA also, So totally 4 s instead of a single .

About | Sitemap | Contact