• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Trouble with JNDI & LDAP

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I'm trying to connect to an LDAP server from a Java application.
The LDAP server is on a Windows2000 server in a different host than the Java application. I'm using the jndi package included in the J2RE 1.3.1.
My test looks as follows:

import javax.naming.*;
import java.util.Hashtable;

public class ldap {

public static void main(String[] args) {
// Set up environment for creating initial context
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");

env.put(Context.PROVIDER_URL, "ldap://******:389/dc=ajtgna,dc=org");
env.put(Context.SECURITY_PRINCIPAL,"cn=Administrador,cn=Users");
env.put(Context.SECURITY_AUTHENTICATION,"********");

String consulta="";

try {
// Create the initial context
Context ctx = new InitialContext(env);
// Read from directory
//System.out.println(ctx.lookup(consulta));
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
System.out.println("Operation failed: " + e);
}
}
}

where ****** are the host name and the user password.
I get the following error:
Operation failed: javax.naming.CommunicationException: ********:389 [Root exception is java.security.AccessControlException: access denied (java.net.SocketPermission ******* resolve)]
The user and password are correct, so I assume there may be a problem in the url or during the connection.
I hope someone can help me. I've looked for information but I don't find anything useful.
I'm sorry about my english, i'm a spanish
Thank you so much!
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a grant for "java.netSocketPermission <server> resolve" in your server's policy file?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, and welcome to the 'ranch!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic