Analytics


Google

Friday, November 30, 2012

JDBC Connection String to Use LDAP


If LDAP allows anonymous.
String ldapHost    = "ldap-server:389";
String context     = ",dc=nl,dc=abnamro,dc=com";
 
String serviceName = "mts-a-de-grid";
String user        = "aldo";
String pass        = "aldo";
String url         = "jdbc:oracle:thin:@ldap://" + ldapHost + "/" + instance + ldap_context;
 
OracleDataSource o = new OracleDataSource();
 
o.setUser(user);
o.setPassword(password);
o.setURL(url);
 
Connection conn = o.getConnection();

If authentication is required:
String url = "jdbc:oracle:thin:@ldap://ldap-server:389/CN=Admin,O=COHERIS,C=FR";
 
 
Properties prop = new Properties();
prop.put("java.naming.security.authentication", "simple");
prop.put("java.naming.security.principal","CN=Admin,O=COHERIS,C=FR");
prop.put("java.naming.security.credentials", "password");
 
OracleDataSource ods = new OracleDataSource();
ods.setURL(url);
ods.setConnectionProperties(prop);

Reference:
  Oracle Forum

No comments: