Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LDAP and JNDI

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heres one;
Im doing a simple LDAP query - the code work fine as an application (using java.exe).
when I cut and paste the function into an applet I get:
Cannot instantite class:com.sun.jndi.Ldap.LdapCtxFactory.
As I mentioned before, the application can find it - why can't the applet???
heres the method code;
private String sortLDAP()
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, " my ldap server");


try
{
DirContext ctx = new InitialDirContext(env);
Attributes answer = ctx.getAttributes("cn = barry, ou=spc, ou=sc");

for (NamingEnumeration ae = answer.getAll(); ae.hasMore()
{
Attribute attr = (Attribute)ae.next();
sDesc += "attribute: " + attr.getID() + "\n";
for (NamingEnumeration e = attr.getAll(); e.hasMore()
{
sDesc += "value: " + e.next() + "\n" ;
}
}

}
catch(NamingException e)
{
sDesc="Exception Thrown: \n" + e.getMessage();
}
return sDesc;
}
any help would be brilliant:
Mike B
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Mike B",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic