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!