|
From: Michael E. <men...@ka...> - 2002-10-27 17:39:53
|
I've been using python-ldap scenario below for a few weeks now:
>
> - against built-in OpenLDAP and the built-in python 2.2: fails with
> the error message that started this whole thread. the _ldap.so shared
> module is not created because linking fails.
Even though it fails with an error the library is already built by that
point so if you do a python setup.py install, it installs python ldap
libraries which do work (at least partially - see below). I've only
tested connecting to a server and doing searches which all work fine
and provide correct results.
BUT, when I try to do a delete or modify, I get an error message that
says:
{'info': 'modifications require authentication', 'desc': 'Operations
error'}
I'm connected (at least it seems like I am) with the rootdn and rootpw
that I have configured in slapd.conf.
From my understanding binding with that user/password should allow me
to modify any entry in the database.
On the other hand maybe this is happening because the python-ldap
library isn't built correctly. I'm very new to LDAP in general so I
can't tell. maybe someone else on this list can help decipher that
error response? BTW, is there any way to determine how an ldap object
is actually bound to the server (e.g., getBoundUserName type of method?)
The code I"m using to do this is based on my own simple LDAPWrapper
class which is this:
import ldap
class LDAPWrapper:
def __init__(self, user="", password=""):
self.server = ldap.open("127.0.0.1")
self.server.simple_bind(user, password)
def search(self, base, filter, scope=ldap.SCOPE_SUBTREE,
retrieveAttributes=None, limit=10):
try:
ldap_result_id = self.server.search(base, scope, filter,
retrieveAttributes)
result_set = []
for i in range(limit):
result_type, result_data = self.server.result(ldap_result_id, 0)
if (result_data == []):
return result_set
else:
if result_type == ldap.RES_SEARCH_ENTRY:
result_set.append(result_data)
return result_set
except ldap.SIZELIMIT_EXCEEDED, e:
print e
def delete(self, dn):
try:
result_type, result_data = self.server.delete_s(dn)
if (result_type == 'RES_DELETE'):
return 1 # true
else:
return 0 # false
except Exception, e:
print e
print "An error occurred during LDAPSearch.delete()"
return None
def close(self):
self.server.unbind()
Any help would be appreciated and I will gladly test builds of
python-ldap on my OS X box since I need this to work for development
purposes.
Cheers
Mike
On Sunday, October 27, 2002, at 10:34 AM, Jens Vagelpohl wrote:
> as far as compiling python-ldap goes, here is the outcome of a couple
> experiments i did yesterday. all were done with the current CVS HEAD:
>
> - against self-compiled OpenLDAP 2.1.4 and self-compiled python 2.1.3:
> no problem.
>
> - against built-in OpenLDAP and self-compiled python 2.1.3: no
> problem. i specified "/usr/lib" as library_dirs and "/usr/include" as
> include_dirs. libs was "ldap_r lber ssl crypto" (sasl did not compile
> - could not find sasl.h, even though OS X has the library itself).
>
> - against built-in OpenLDAP and the built-in python 2.2: fails with
> the error message that started this whole thread. the _ldap.so shared
> module is not created because linking fails.
>
> it seems that the culprit might be the built-in python2.2. the python
> build flags, i assume, govern the build flags used when compiling
> these extension modules.
>
> jens
|