Hi all,
I'm having a problem with using JNDI to connect to LDAP via SSL in the SAP Portal. I have searched through the archives of this forum for similar issues, and although I see other people reporting the same issue, I have not seen anyone post what they did to solve the problem.
Here is my code:
Hashtable env = new Hashtable();
try {
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
String ldapUrl = "ldaps://myserver.mydomain.com:636/";
env.put(Context.SECURITY_PRINCIPAL,"myuser");
env.put(Context.SECURITY_CREDENTIALS,"mypassword");
env.put(Context.PROVIDER_URL, ldapUrl);
DirContext dctx = new InitialDirContext(env);
String base = "OU=SUPMOBILEUSERS,DC=DEVEXTAUTH,DC=GRAYBAR,DC=COM";
SearchControls sc = new SearchControls();
String[] attributeFilter = { "objectCategory","sAMAccountName","sn","givenName","mail"};
sc.setReturningAttributes(attributeFilter);
sc.setSearchScope(SearchControls.SUBTREE_SCOPE);
String filter = "(&(sn=*))";
NamingEnumeration results = dctx.search(base, filter, sc);
while (results.hasMore()) {
SearchResult sr = (SearchResult) results.next();
System.out.println("search result = " + sr.toString());
}
dctx.close();
} catch (Exception e) {
e.printStackTrace();
}
The error that I'm getting is:
javax.naming.CommunicationException: simple bind failed: myserver.mydomain.com:636 [Root exception is javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: No trusted certificate found]
We have uploaded the LDAP server's certificate in the TrustedCAS of the keystore in Visual Admin but continue to get this error.
I know that in java outside of the SAP Portal, the way to indicate the keystore is to include it in the command that you are using. For example:
java -Djavax.net.ssl.trustStore="C:\jdk\jre\lib\security\cacerts" MyClass
I'm thinking that there must be something that I need to do in the code or in Visual Admin to indicate the keystore to use.
Can anyone please help me out?
Thanks!
-StephenS