Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

javax.naming.directory.NoSuchAttributeException

  Asked By: Lamberta    Date: Jul 26    Category: Java    Views: 2058
  

I have compiled and run the following program. I see the exception:


"Operation failed: javax.naming.directory.NoSuchAttributeException:
[LDAP: error code 16 - 00000057
: LdapErr: DSID-0C09098B, comment: Error in attribute conversion
operation, data 0, v893 ]; remain
ing name 'ou=favorite, ou=Fruits'"

class Bind {
public static void main(String[] args) {

// Set up the environment for creating the initial context
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put
(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");

try {
// Create the initial context
DirContext ctx = new InitialDirContext(env);

// Create object to be bound
Fruit fruit = new Fruit("orange");

// Create attributes to be associated with object
Attributes attrs = new BasicAttributes(true); // case-
ignore
Attribute objclass = new BasicAttribute("objectclass");
objclass.add("top");
objclass.add("organizationalUnit");
attrs.put(objclass);

// Perform bind
ctx.bind("ou=favorite, ou=Fruits", fruit, attrs);

// Check that it is bound
Object obj = ctx.lookup("ou=favorite, ou=Fruits");
System.out.println(obj);

// Get its attributes
Attributes retattrs = ctx.getAttributes("ou=favorite,
ou=Fruits");
GetattrsAll.printAttrs(retattrs);

// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.out.println("Operation failed: " + e);
}
}
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on javax.naming.directory.NoSuchAttributeException Or get search suggestion and latest updates.