cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Connect to LDAP from UDF on secured port

Former Member
0 Kudos

PI version is 7.02.

I am trying to connect to LDAP on a secured port. Basis has imported the certifcates in Keystore view.

I have a standalone jave program on my desktop and it sucessfully connected to LDAP on secured port.

Questions

1) Do I need to specify the lcoation of the certificates explicity in UDF code?

2) If so how to set the location of the certificates in the UDF

3) In my standalone java program, I have 2 statements

String keystore = "C:\\keystore";

      System.setProperty ( "javax.net.ssl.trustStore", keystore );

      System.setProperty("javax.net.ssl.keyStorePassword", "changeit");

How these need to be translated while connecting from UDF

Below is my UDF code. Please advise.

   //write your code here

   String usr ="" ;
   String a = "";
   String b = "\\";
   String ldap_server = "ldap://adapp.abcd.aost.COM:329/";
   Properties ldap_properties;
   String ldap_principal = "";
   String ldap_credentials = "";
                                              

                                                a = domain.concat (b);
                                                 usr = a.concat(user) ;
                                                 ldap_principal = usr;
                                                 ldap_credentials = pwd;

  // Pre-initialize LDAP connection related properties
  ldap_properties = new Properties();
  ldap_properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
  ldap_properties.put(Context.PROVIDER_URL, ldap_server);
  ldap_properties.put(Context.SECURITY_AUTHENTICATION, "simple");
  ldap_properties.put(Context.SECURITY_PROTOCOL, "ssl");
  ldap_properties.put(Context.SECURITY_PRINCIPAL,  ldap_principal );
  ldap_properties.put(Context.SECURITY_CREDENTIALS, ldap_credentials);
 
                                               
     
   String keystore ="/opt/sap/ad1/DVEBMGS02/sec/";
  System.setProperty("javax.net.ssl.keyStore", keystore);
 
  ldap_properties.put("com.sun.jndi.ldap.read.timeout", "100000");
  ldap_properties.put("com.sun.jndi.ldap.connect.timeout", "10000");
  ldap_properties.put("com.sun.jndi.ldap.connect.pool", "false");


  String returnValue = "X";
  InitialDirContext ctx = null;


  // Connect the LDAP
  try {
   ctx = new InitialDirContext(ldap_properties);
   if (ctx != null) {
    returnValue = "Y";
   }


  } catch (Exception eom) {
   //System.out.println("LDAP exception");
   eom.printStackTrace();
                          return returnValue;
  } finally {
   try {
    if (ctx != null)
     ctx.close();
   } catch (NamingException eo) {
    // nothing
   } catch (NullPointerException eo) {
    // Nothing
   }
  }
                           return returnValue;
 

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Already found solution? Having same issue by accessing the keystore from java proxy.

Thanks in advance for your feedback.

former_member185846
Active Participant
0 Kudos

Were you able to fix this? I'm stuck up with a similar issue.

Thanks