By: sashi bhusan user 26 Nov 2019 at 5:36 a.m. CST

4 Responses
sashi bhusan gravatar
I have installed python-ldap (pip install python-ldap) running the command inside the gluu/python/libs directory. (before python-ldap installation i have run the following command sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev) Th****en , ldap package is availble as can be seen below root@gluuserver4-221119:/opt/gluu/python/libs# python Python 2.7.12 (default, Oct 8 2019, 14:14:10) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ldap >>> ldap.__version__ '2.4.22' but while importing (import ldap) inside interception script it shows the following error Caused by: Traceback (most recent call last): File "py_ldap.py", line 14, in <module> File "/opt/gluu/python/libs/ldap/__init__.py", line 22, in <module> import _ldap ImportError: No module named _ldap

By Mohit Mali staff 26 Nov 2019 at 5:51 a.m. CST

Mohit Mali gravatar
hi Sashi bhusan, Thanks and reaching out gluu support , I will help you with this ticket. just a quick question have you login onto gluu container before running the install command ? try to login on the container. a) service gluu-server login b) then run the command. Thanks and Regards Mohit Mali

By sashi bhusan user 26 Nov 2019 at 6:27 a.m. CST

sashi bhusan gravatar
i have done all these stuffs but still its showing no module name ldap.

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

Mohit Mali gravatar
hi Sashi bhusan , I just get some information from developer ,the step that’s missing is opening the file /etc/gluu/conf/ox-ldap.properties, 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:46 a.m. CST

Mohit Mali gravatar
Hi Sashi, 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 javax.naming.directory 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 = ctx.search(search_start, search_target, srch ) #Display Search for result in results: attributes = result.getAttributes() for atr in attributes.getAll(): print atr print "-"*20 ```