Add LDAP Server Error [RESOLVED]

Because I have two LDAP servers, I noticed that I cannot add the second one in Plone. When I click Add LDAP Server, the following error occurs:
Traceback (innermost last):

Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module zope.formlib.form, line 800, in __call__
Module zope.formlib.form, line 920, in render
Module zope.formlib.form, line 790, in render
Module zope.browserpage.namedtemplate, line 60, in __get__
Module zope.component._api, line 96, in getAdapter

ComponentLookupError: (<Products.Five.metaclass.ServerAddForm object at 0x7fe0f4888450>, <InterfaceClass zope.browserpage.namedtemplate.INamedTemplate>, 'default')

In ZMI /acl_users/ldap-plugin/acl_users > LDAP servers, I can add another LDAP server without a problem. However, I cannot "define which servers to connect to on the form" even though it is stated on the page that I can do so.

Any help would be most appreciated. Thank you.

This is a bug: apparently, a ZCML registration is missing (registering an INamedTemplate adapter with name default for ServerAddForm). When I remember right, five.formlib is suppose to register such a generic adapter (I may well be wrong); maybe, your buildout.cfg does not include five.formlib?.

Thank you so much for your response, Dieter.

The following is in my buildout:
eggs += plone.app.ldap five.formlib plone.app.form

zcml =

Do I need to add anything in the section of "zcml =" in my buildout?

The following dependencies were pulled in when I ran my buildout:
Products.CMFDefault 2.2.4 Products.LDAPMultiPlugins 1.14 Products.PloneLDAP 1.2 dataflake.fakeldap 1.1 five.formlib 1.0.4 plone.app.form 2.3.2 python-ldap 2.4.22

My Plone version is the following:
Plone 5.0.7 (5017) CMF 2.2.10 Zope 2.13.26 Python 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] PIL 3.4.2 (Pillow)

1 Like

five.formlib comes with both a meta.zcml as well as a configure.zcml. If you add five.formlib to the zcml definition, then the corresponding configure.zcml will be read in during startup. There is a special naming convention (when I remember right, it is a :meta suffix - check the buildout documentation) to indicate loading of the meta.zcml.

Many packages used in the context of Plone are set up to use z3c.autoinclude. Then, their zcml resources are automatically loaded (no need to extend the zcml variable). Checking, I have not found a hint that five.formlib belongs to those packages.

Dieter,

I added this to my buildout.cfg:
zcml = five.formlib

I then tried to add another LDAP server in Plone and the same errors are still showing:
Traceback (innermost last): Module ZPublisher.Publish, line 138, in publish Module ZPublisher.mapply, line 77, in mapply Module ZPublisher.Publish, line 48, in call_object Module zope.formlib.form, line 800, in __call__ Module zope.formlib.form, line 920, in render Module zope.formlib.form, line 790, in render Module zope.browserpage.namedtemplate, line 60, in __get__ Module zope.component._api, line 96, in getAdapter ComponentLookupError: (<Products.Five.metaclass.ServerAddForm object at 0xa92bd90>, <InterfaceClass zope.browserpage.namedtemplate.INamedTemplate>, 'default')

Are you sure to have rerun buildout after the change?

I have looked around and have found that the component registration is in zope.formlib:configure.zcml with the definition in zope.formlib.form.default_page_template. It is activated via the five.formlib zcml.

Thus, if you have run buildout and you still see the problem, then something else is wrong. A possible reason could be a programming error for the ServerAddForm. It must implement IPageForm that the adapter registration gets effective for it.

It is also possible that the package which provides the LDAP plugin comes with its own ZCML registrations and that those are not activated. Check that you have honored all installation requirements of this package.

If everything looks correct on your side, you might consider contacting the authors of that plugin.

Over the past year or so it has seemed clear to me (based on lots of posts here) that Plone 5 works much better with pas.plugins.ldap.

Kim,

Thanks so much. When I went to pas.plugins.ldap in pypi at https://pypi.python.org/pypi/pas.plugins.ldap, I see build failing and coverage is at 67%. Is this an indication that it is not quite ready for Plone 5? How should I interpret those numbers?

It works with Plone 5. I don't know why the build failed. Coverage being low wouldn't be an indicator of it not running.

Thanks Kim. I have now installed pas.plugins.ldap:
If I want to connect through port 389, am I right to connect in the following way?
ldap://ldap.domain.com:389

If I want to connect through port 636 over SSL like I could do so with Products.PloneLDAP 1.2?
ldaps://ldap.domain.com:636

Seems right but I haven't used this in a while myself.

Also seems right. Just try it and see :slight_smile:

So I have installed a new Plone without anything in it and tried to connect with my ldap server. For some reason, I keep getting this error:
ERROR: Exception in Users; 'cn'

Any advise would be most appreciate. Thanks.

If this is an exception from your Plone, then you have a chance to get a traceback for it. It shows where exactly in the code the exception was raised. Look in the "error_log" object of your Plone site (it is likely necessary to authenticate as "Emergency User" or Zope "Manager" via the "acl_users" in the root - as authentication in your Plone site likely does not work).

If you do not get a traceback, then you could try to search for the string Exception in in the source hierarchy to find out from where the exception comes. There, you could add a logging call (something like logger.exception(...) and get the corresponding traceback in the log file.

cn is a common LDAP attribute ("Common Name"); maybe, your LDAP server does not provide it and the code expects it -- but the traceback should provide better hints toward an understanding of the problem.

Dieter, thanks for your advice. I have reverted back to plone.app.ldap which seems so much more user friendly and I got things to work now. It was my connection from my server to the Windows Active Directory via LDAP over port 636 that was messed up. Once I got that working, it was working in Plone as well. Thanks so much for your help. Cheers.