LDAP Policy throwing "com.unboundid.ldap.sdk.BindRequest - Internal Server Error

We are trying to use LDAP policy with external LDAP for authentication.

We followed steps provided in https://docs.apigee.com/api-platform/reference/policies/ldap-policy

and also created LdapResource "ldap1" by using curl command as per document.

We have also added UnboundID LDAP SDK jar file as per the document

Belowldap-policy.txt is the LDAP policy we have attached.

When testing throw postman got below exception.

{ "fault": { "faultstring": "com/unboundid/ldap/sdk/BindRequest", "detail": { "errorcode": "Internal Server Error" } } }

Please help me out to resolve this issue and let me know if i am doing wrong.

0 4 465
4 REPLIES 4

That's unfortunate. The error message is not very helpful.

If I were diagnosing this, I would check the MP logs, to see if there is a more helpful message or stacktrace.

Hi Dino, I have checked with MP logs and I got the below error message

and as per the document we have added the unboundid-ldapsdk-se.jar file in /opt/apigee/edge-gateway/lib/thirdparty directory.

MP ERROR LOGS:

WARN S.HTTPCLIENTSERVICE - DNSCache$2.failed() : Failed to resolve hostname endpointURL.com. Reason endpointURL.com: Name or service not known. This log message will snooze for 2 hours Apigee-Main-8 ERROR STEPS.LDAP_STEP_EXECUTION - LdapStepExecution.onException() : LdapStepExecution(LDAP).onException() : Error occurred java.lang.NoClassDefFoundError: com/unboundid/ldap/sdk/BindRequest at com.apigee.messaging.runtime.ExternalLdapConnectionFactory.getConnectionProvider(ExternalLdapConnectionFactory.java:38) at com.apigee.steps.ldap.LdapStepExecution.execute(LdapStepExecution.java:52) at com.apigee.messaging.runtime.steps.StepExecution.execute(StepExecution.java:156) at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:74) at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:45) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.ClassNotFoundException: com.unboundid.ldap.sdk.BindRequest at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 11 common frames omitted 2019-10-23 15:23:20,768 Apigee-Main-8 ERROR STEPS.LDAP_STEP_EXECUTION - LdapStepExecution.onFault() : LdapStepExecution(LDAP).onException() : Error occurred java.lang.NoClassDefFoundError: com/unboundid/ldap/sdk/BindRequest at com.apigee.messaging.runtime.ExternalLdapConnectionFactory.getConnectionProvider(ExternalLdapConnectionFactory.java:38) at com.apigee.steps.ldap.LdapStepExecution.execute(LdapStepExecution.java:52) at com.apigee.messaging.runtime.steps.StepExecution.execute(StepExecution.java:156) at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:74) at com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:45) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.ClassNotFoundException: com.unboundid.ldap.sdk.BindRequest at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 11 common frames omitted

Show me the LDAP Resource definition.

Also, The error i see:

java.lang.NoClassDefFoundError: com/unboundid/ldap/sdk/BindRequest 

...is helpful. The message is telling you that the MP cannot find the unboundid jar. Have you restarted the MP after you added the jar?

Have you verified that the jar contains what it should contain? Where did you get the unboundid jar?

Check the version. The last time I tried this i used v 2.3.8 of the unboundid jar, and it worked. I see the current version is now 4.0.12. I'm not sure if there have been incompatible interface changes between 2.3 and 4.0. Maybe you could try an older version.

If you like, you can try the jndi provider, in lieu of the unboundid provider. You would need to modify your LDAP resource, or create a different one, specifying the JNDI provider, and refer to *that one* in the LDAP policy. That also worked for me.

Not applicable

add jar in the file structure with permissions to apigee user. Sometimes the jar gets corrupted or the permission is insufficient which causes this error.