By: Dibyajyoti Parida user 26 Nov 2019 at 11:21 p.m. CST

10 Responses
Dibyajyoti Parida gravatar
I have installed python-ldap library inside the gluu server container. (pip install python-ldap) My goal is to import the ldap module inside the interception script. But its showing like the following error Caused by: Traceback (most recent call last): File "", line 14, in <module> File "/opt/gluu/python/libs/ldap/", line 22, in <module> import _ldap ImportError: No module named _ldap Please help me on this. Regards.

By Mohit Mali staff 26 Nov 2019 at 11:27 p.m. CST

Mohit Mali gravatar
Hi Dibyajyoti Parida, Thanks for reaching out gluu support , I will assist you on this ticket , let me pull information from script developer and get back to you asap. Thanks and Regards Mohit Mali

By Dibyajyoti Parida user 26 Nov 2019 at 11:32 p.m. CST

Dibyajyoti Parida gravatar
Thanks Mohit Mali, It would be great, if I can get the solution in shorter time period. Regards. Dibyajyoti Parida

By Mohit Mali staff 26 Nov 2019 at 11:59 p.m. CST

Mohit Mali gravatar
hi Dibyajyoti Parida, I just get some information from developer ,the step that’s missing is opening the file /etc/gluu/conf/, finding the property entry pythonModulesDir and appending the value /opt/jython-<version>/Lib/site-packages to the existing value. Directories appended there are column separated (:) Hope this will resolve your issue. Thanks and Regards Mohit Mali

By Mohit Mali staff 27 Nov 2019 at 1:45 a.m. CST

Mohit Mali gravatar
Hi DibyaJyoti, I had a word with my senior developer , we cannot using any python module which require c compilation because in gluu we are using jython rather than python so pip install won't work , you can still use java native library for ldap. ``` # Jython LDAP Example from javax.naming import * from java.util import * from import * # Credentials to access LDAP user = "cn=Directory Manager" passwd = "TopSEcret" # Query starting point and query target search_start = "ou=people,o=gluu" search_target = "(objectClass=gluuPerson)" # Setup LDAP Context Options settings = Hashtable() settings.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory") settings.put(Context.PROVIDER_URL, "ldaps://localhost:1636") settings.put(Context.SECURITY_PRINCIPAL, user) settings.put(Context.SECURITY_CREDENTIALS, passwd) # Connect to LDAP Server ctx = InitialDirContext(settings) srch = SearchControls() srch.setSearchScope(SearchControls.SUBTREE_SCOPE) # Execute LDAP Search results =, search_target, srch ) #Display Search for result in results: attributes = result.getAttributes() for atr in attributes.getAll(): print atr print "-"*20 ```

By Dibyajyoti Parida user 27 Nov 2019 at 4:22 a.m. CST

Dibyajyoti Parida gravatar
Hi Mohit Mali, when I am trying with the code you have shared, its showing the the error below org.gluu.exception.PythonException: Failed to load python file '' at org.gluu.service.PythonService.loadPythonScript( at org.gluu.service.PythonService$Proxy$_$$_WeldClientProxy.loadPythonScript(Unknown Source) at org.gluu.service.custom.script.CustomScriptManager.createExternalTypeFromStringWithPythonException( at org.gluu.service.custom.script.CustomScriptManager$Proxy$_$$_WeldSubclass.createExternalTypeFromStringWithPythonException(Unknown Source) at org.gluu.service.custom.script.CustomScriptManager.createExternalType( at org.gluu.service.custom.script.CustomScriptManager.reloadCustomScriptConfigurations( at org.gluu.service.custom.script.CustomScriptManager.reloadImpl( at org.gluu.service.custom.script.CustomScriptManager.reload( at org.gluu.service.custom.script.CustomScriptManager.reloadTimerEvent( at org.gluu.service.custom.script.CustomScriptManager$Proxy$_$$_WeldSubclass.reloadTimerEvent(Unknown Source) at sun.reflect.GeneratedMethodAccessor145.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke( at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke( at org.jboss.weld.injection.MethodInvocationStrategy$SimpleMethodInvocationStrategy.invoke( at org.jboss.weld.event.ObserverMethodImpl.sendEvent( at org.jboss.weld.event.ObserverMethodImpl.sendEvent( at org.jboss.weld.event.ObserverMethodImpl.notify( at javax.enterprise.inject.spi.ObserverMethod.notify( at org.jboss.weld.util.Observers.notify( at org.jboss.weld.event.ObserverNotifier.notifySyncObservers( at org.jboss.weld.event.ObserverNotifier.notify( at org.jboss.weld.event.ObserverNotifier.fireEvent( at org.jboss.weld.event.ObserverNotifier.fireEvent( at org.jboss.weld.manager.BeanManagerImpl.fireEvent( at org.jboss.weld.util.ForwardingBeanManager.fireEvent( at org.gluu.service.timer.TimerJob.execute( at org.gluu.service.timer.JobExecutionDelegate.execute( at at org.quartz.simpl.SimpleThreadPool$ Caused by: Traceback (most recent call last): File "", line 15, in <module> ImportError: No module named directory

By Mohit Mali staff 27 Nov 2019 at 5:48 a.m. CST

Mohit Mali gravatar
Hi Dibyajyoti Parida, ok we are looking on this , may i know what is your objective to achieve by writing those script ?. Thanks and Regards Mohit Mali

By Dibyajyoti Parida user 27 Nov 2019 at 5:57 a.m. CST

Dibyajyoti Parida gravatar
Hi Mohit Mali, We are trying to authenticate users whose password is stored in LDAP. We have to do it through interception script. Basic need is to fetch something from LDAP from interception script.

By Dibyajyoti Parida user 27 Nov 2019 at 7:35 a.m. CST

Dibyajyoti Parida gravatar
Hi Mohit, We seek your urgent help on this . We are importing necessesary classes/modules as below but why its failing with ? Often its also failing complaining about javax or java.util.Hastable etc. ``` import java import javax from org.xdi.service.cdi.util import CdiUtil from import Identity from org.xdi.model.custom.script.type.auth import PersonAuthenticationType from org.xdi.oxauth.service import AuthenticationService from org.xdi.util import StringHelper from javax.naming import Context from java.util import Hashtable from import SearchControls from import InitialDirContext ``` Please suggest how we can use these native java classes.

By William Lowe staff 02 Dec 2019 at 7:12 p.m. CST

William Lowe gravatar
I believe this has been resolved. Dibyajyoti, can you please post notes about your resolution?

By Dibyajyoti Parida user 31 Dec 2019 at 1:55 a.m. CST

Dibyajyoti Parida gravatar
we did not go python way..we went jython way and we never required any library.