0

I'm in trouble with connecting Active Directory. The codes in question is following:

Hashtable<Stirng,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://192.168.0.100:389");
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,"TEST\\Administrator");
env.put(Context.SECURITY_CREDENTIALS,"password");
LdapContext ctx = new InitialLdapContext(env, null);

When I debug it, it gives me an error:

javax.naming.CommunicationException: 192.168.0.100:389 [Root Exception is java.security.AccessControlException: access denied ("java.net.SocketPermission" "192.168.0.100:389" "connect.resolve")]

An IP I'm trying to connect is 192.168.0.99 (Windows 7) 192.168.0.100 is installed Windows 2008, and I double-checked that the connection doesn't have any problems when I try to connect from 192.168.0.100 itself. Could you give me a piece of advice please? I'm happy to provide more information if needed

rkosegi
  • 14,165
  • 5
  • 50
  • 83
Web2py user
  • 73
  • 2
  • 11

1 Answers1

2

I found out what was wrong. I added

grant
{
    permission java.net.SocketPermission "*:1024-65535","connect,accept,resolve";
    permission java.net.SocketPermission "*:1-1023","connect,resolve";
};

in policy file (which was catalina.policy for me) Then, I added a statement in Arguments of Run configuration in eclipse as:

-Djava.security.policy="c:\catalina.policy"

Thanks

Web2py user
  • 73
  • 2
  • 11