Quantcast
Channel: SCN : All Content - Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 7030

Unable to Connect to LDAP from UDF on secured port

$
0
0

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;
 


Viewing all articles
Browse latest Browse all 7030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>