[Zope] Accessing openLDAP Server from Python Script inside a Zope CMF.

Ashish Gautam AshishG@lambenttek.com
Tue, 16 Jul 2002 18:06:59 +0530


Hi all,
I am trying to access openLDAP server from a python script inside CMF site
of Zope.
I have python-ldap module installed on a linux machine.
My final intention is to Add an LDAP entry in to LDAP server.
Following code i have written in a python script  just to get started by
connecting to LDAP server and accessing the existing contents.
My approach to add an entry from python script is correct or its bound to
fail?

Script starts:

import ldap

ldapCon = ldap.open("localhost")

ldapCon.simple_bind_s("cn=Manager,o=Lambent","secret");

print ldapCon.search_s("ou=HR,o=Lambent",ldap.SCOPE_SUBTREE,"objectclass=*")

return printed

Script ends.

I am clueless as to what is causing this problem.

Following error i have encountered :


An error was encountered while publishing this resource.

Error Type: Unauthorized
Error Value: You are not allowed to access open in this context



Troubleshooting Suggestions

The URL may be incorrect.
The parameters passed to this resource may be incorrect.
A resource that this resource relies on may be encountering an error.

For more detailed information about the error, please refer to the HTML
source for this page.

If the error persists please contact the site maintainer. Thank you for your
patience.

Traceback (innermost last):
  File /usr/local/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
  File /usr/local/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 114, in
publish
  File /usr/local/Zope2.5.1/lib/python/Zope/__init__.py, line 159, in
zpublisher_exception_hook
    (Object: testsite)
  File /usr/local/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 98, in
publish
  File /usr/local/Zope2.5.1/lib/python/ZPublisher/mapply.py, line 88, in
mapply
    (Object: ldap)
  File /usr/local/Zope2.5.1/lib/python/ZPublisher/Publish.py, line 39, in
call_object
    (Object: ldap)
  File /usr/local/Zope2.5.1/lib/python/Shared/DC/Scripts/Bindings.py, line
252, in __call__
    (Object: ldap)
  File /usr/local/Zope2.5.1/lib/python/Shared/DC/Scripts/Bindings.py, line
283, in _bindAndExec
    (Object: ldap)
  File
/usr/local/Zope2.5.1/lib/python/Products/PythonScripts/PythonScript.py, line
302, in _exec
    (Object: ldap)
    (Info: ({'script': <PythonScript instance at 8bbbeb0>, 'context':
<CMFSite instance at 8b10098>, 'container': <CMFSite instance at 8b10098>,
'traverse_subpath': []}, (), {}, None))
  File Script (Python), line 7, in ldap
  File /usr/local/Zope2.5.1/lib/python/AccessControl/ZopeGuards.py, line 60,
in guarded_getattr
    (Object: ldap)
  File /usr/local/Zope2.5.1/lib/python/AccessControl/SecurityManager.py,
line 83, in validate
  File /usr/local/Zope2.5.1/lib/python/AccessControl/ZopeSecurityPolicy.py,
line 145, in validate
Unauthorized: (see above)


Plz reply ASAP,

Regards
Ashish.