LDAP search using Python without LDAP library

Here's the problem - I have to work with the Blackboxed Linux app server - in other words, I have to work with what I have, I cannot add any libraries.

I need to find an LDAP directory and return user data using Python.

Usually easy ... import ldap

Also, I can't, I don't have an LDAP library to use and can't install it.

Look for suggestions for a way to do this - you need something better than pounding to curl

+3


source to share


1 answer


you can copy installed python-ldap modules (site-packages / ldap) to directory; then add that directory to the path. then you can import it.

$ cp -R 'site-packages/ldap' 'path-to-local-packages'

>>> import sys
>>> sys.path.append('path-to-local-packages')
>>> import ldap

      

If it doesn't work; you can also use imp.load_source to load the module dynamically. There are more methods in the imp module that you can test.



- tested

I had to do this myself today and it worked fine. I wanted to download the "python-ldap" library installed in a virtual env in PythonWin (which does not support venv); I am running the commands below:

>>> import sys
>>> sys.path.append(r'C:\Users\PyGuy\.virtualenvs\pyad\Lib\site-packages\python_ldap-2.4.15-py2.7-win32.egg')
>>> import ldap
>>>

      

+1


source







All Articles