gdub / python-simpleldap Goto Github PK
View Code? Open in Web Editor NEWA module that makes simple LDAP usage simple.
License: MIT License
A module that makes simple LDAP usage simple.
License: MIT License
[root@reports-hammer-local tests]# pip install simpleldap
Requirement already satisfied (use --upgrade to upgrade): simpleldap in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): python-ldap in /usr/local/lib/python2.7/site-packages (from simpleldap)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages/setuptools-1.4.2-py2.7.egg (from python-ldap->simpleldap)
Cleaning up...
[root@reports-hammer-local tests]# python tests.py
Traceback (most recent call last):
File "tests.py", line 7, in
import simpleldap
ImportError: No module named simpleldap
I'm not sure how to fix this. Help?
I'm periodically getting this error from my Python script, mostly when I'm trying to unbind the LDAP connection:
ldap_connection.unbind()
Any suggestions on why this is happening and what I need to do to fix it?
Hi,
would it be feasible to include Python3 compatibility (through 2to3 at least).
Installing via pip breaks in Py3:
print name + ': ' + cfg.get('_ldap', name)
^
SyntaxError: invalid syntax
It's not clear to me whether this is a bug or I'm doing something wrong. I'm able to make a connection, but then any attempt to use that connection says I'm not connected:
with simpleldap.Connection('directory.example.com') as conn:
is_valid = conn.authenticate('uid=myuser,dc=directory,dc=example,dc=com', 'password')
(with my own substitutions of course) I get :
>>> is_valid
True
but then:
conn.search("(&(givenName=Joe))")
returns
ldap.LDAPError: LDAP connection invalid
I've run into a number of occasions where the exceptions raised are actually from the ldap module, and not from simpleldap
Traceback (most recent call last):
File "ldap_experiments.py", line 53, in <module>
conn = simpleldap.Connection(hostname=LDAP_SERVER, dn=QUERY_USERNAME, password=QUERY_PASS)
File "/usr/local/lib/python2.7/site-packages/simpleldap/__init__.py", line 175, in __init__
self.connection.simple_bind_s(dn, password)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 222, in simple_bind_s
msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 216, in simple_bind
return self._ldap_call(self._l.simple_bind,who,cred,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 106, in _ldap_call
result = func(*args,**kwargs)
ldap.SERVER_DOWN: {'desc': "Can't contact LDAP server"}
Traceback (most recent call last):
File "ldap_experiments.py", line 53, in <module>
user = conn.get("sAMAccountName=chrisf")
File "/usr/local/lib/python2.7/site-packages/simpleldap/__init__.py", line 247, in get
results = self.search(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/simpleldap/__init__.py", line 236, in search
base_dn, scope, filter, attrs, timeout=timeout, sizelimit=limit)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 591, in search_ext_s
return self.result(msgid,all=1,timeout=timeout)[1]
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 503, in result
resp_type, resp_data, resp_msgid = self.result2(msgid,all,timeout)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 507, in result2
resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all,timeout)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 514, in result3
resp_ctrl_classes=resp_ctrl_classes
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 521, in result4
ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)
File "/usr/local/lib/python2.7/site-packages/ldap/ldapobject.py", line 106, in _ldap_call
result = func(*args,**kwargs)
ldap.NO_SUCH_OBJECT: {'info': "0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:\n\t''\n", 'desc': 'No such object'}
etc.
Is this intended behaviour ? Obviously it then means I need to understand the underlaying ldap library and any exceptions that it might through, if simpleldap isn't going to catch and simplify them. I could make a pull request, but its going to significantly affect the behaviour, and anyone currently using it.
Hi,
I'm trying to use simpleldap as installed from pip (version 0.8) and trying to issue a very simple connection:
self.conn = simpleldap.Connection(hostname=self.hostname, dn=self.dn, password=self.password, encryption=self.encryption, require_cert=False)
but I'm getting the following error:
Traceback (most recent call last):
File "ldap.py", line 3, in <module>
import logging, yaml, simpleldap
File "/usr/local/lib/python2.7/dist-packages/simpleldap/__init__.py", line 93, in <module>
class Connection(object):
File "/usr/local/lib/python2.7/dist-packages/simpleldap/__init__.py", line 105, in Connection
ldap.NO_SUCH_OBJECT, # e.g. dn matches no objects.
AttributeError: 'module' object has no attribute 'NO_SUCH_OBJECT'
Am I missing something?
Thanks!
Most LDAP servers do have server side limits regarding the number of entries they do return to the clients, and this limits cannot be changed by the client (it's not the client specified limit).
A couple of years a ago I wrote a similar library that was on top of python-ldap, that was hiding all the complexity of working with paginated results and I would like to make it public.
Imagine that in my case I do have to work with an a tree of LDAP/AD servers that do return ~14.000 users and ~20.000 groups, and the server side limit is 1000. It would be impossible to work without pagination.
Now, my question is if I should add yet-another-ldap-pypi package or I should add my features to an existing one, like this one. Ideally I would like to bring my changes to python-ldap itself but I guess that's much harder.
What do you think about this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.