Display user attributes obtained from ldap through pas.plugins.ldap in the author page

Hi

I have a plone 5.1.4 site connected to ldap (Active Directory) using pas.plugins.ldap and that appears to be working quite well. I have linked the fields in the "User Property-Sheet Attributes" such as "mobile" and "phone" and I have added 2 new fields in the "Member Fields" tab for those 2 attributes. When I search in Users I can see the fields are showing the values from ldap. Where I am running into trouble is understanding how I can get those to display in the author page so when you search in the default user folder and then view a users information you can see their phone and mobile number.
I have tried modifying author.pt using the same format as location but I get the following error:

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 Products.CMFPlone.browser.author, line 265, in __call__
Module Products.Five.browser.pagetemplatefile, line 125, in __call__
Module Products.Five.browser.pagetemplatefile, line 59, in __call__
Module zope.pagetemplate.pagetemplate, line 137, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module 60923e4106663cfd210fd67515c7367b.py, line 1654, in render
Module 3261486b7fa59226ce4999b2db805d3e.py, line 1227, in render_master
Module 60923e4106663cfd210fd67515c7367b.py, line 1642, in __fill_content
Module 60923e4106663cfd210fd67515c7367b.py, line 942, in render_main
Module five.pt.expressions, line 154, in __call__
Module five.pt.expressions, line 126, in traverse
Module zope.traversing.adapters, line 142, in traversePathElement
__traceback_info__: ({'username': u'deand', 'description': 'test user for our systems - used for all internal access and settings', 'language': '', 'home_page': '', 'has_email': True, 'location': 'Main Office', 'fullname': 'Dean Dummy'}, 'phone')
Module zope.traversing.adapters, line 56, in traverse
__traceback_info__: ({'username': u'deand', 'description': 'test user for our systems - used for all internal access and settings', 'language': '', 'home_page': '', 'has_email': True, 'location': 'Main Office', 'fullname': 'Dean Dummy'}, 'phone', ())

LocationError: ({'username': u'deand', 'description': 'test user for our systems - used for all internal access and settings', 'language': '', 'home_page': '', 'has_email': True, 'location': 'Main Office', 'fullname': 'Dean Dummy'}, 'phone')

  • Expression: "authorinfo/phone"
  • Filename: ... -py2.7.egg/Products/CMFPlone/browser/templates/author.pt
  • Location: (line 105: col 27)
  • Source: <tal:phone condition="authorinfo/phone">
    ^^^^^^^^^^^^^^^^
  • Arguments: repeat: {...} (0)
    template: <ViewPageTemplateFile - at 0x7fd2006de290>
    views: <ViewMapper - at 0x7fd2006de490>
    modules: <instance - at 0x7fd21a67c5a8>
    args: <tuple - at 0x7fd225cff050>
    here: <ImplicitAcquisitionWrapper council at 0x7fd2086bb9b0>
    user: <ImplicitAcquisitionWrapper - at 0x7fd20877cb90>
    loop: {...} (0)
    nothing: <NoneType - at 0x563c85f11ae0>
    container: <ImplicitAcquisitionWrapper council at 0x7fd2086bb9b0>
    request: <instance - at 0x7fd2084f42d8>
    wrapped_repeat: <SafeMapping - at 0x7fd2006dd838>
    traverse_subpath: <list - at 0x7fd203bff560>
    default: <object - at 0x7fd225cd5ab0>
    context: <ImplicitAcquisitionWrapper council at 0x7fd2086bb9b0>
    view: <SimpleViewClass from /opt/plone5/buildout-cache/eggs/Products.CMFPlone-5.1.4-py2.7.egg/Products/CMFPlone/browser/templates/author.pt author at 0x7fd200625490>
    translate: <function translate at 0x7fd1ff474578>
    root: <ImplicitAcquisitionWrapper Zope at 0x7fd2087137d0>
    options: {...} (0)
    target_language: <NoneType - at 0x563c85f11ae0>

I have not been able to find any documentation that I can understand well enough how to get access to those fields I have added through the author.pt file and was hoping I could get some advice on what else is required.

Thank you

Don't know if that is the problem in your case, but we had to adjust the order of the Properties plugin. The ldap plugin must come first, otherwise member data will not show correct. You can do this in the http://localhost:8080/Plone/acl_users/plugins/manage_plugins?plugin_type=IPropertiesPlugin form.

1 Like

One one hand order matters. The properties plugins are collecting the fields cascaded, so it looks for a field in the first, if not found in the second and so on. So, if you dont plan to override LDAP read properties with local (ZODB) properties, LDAP first is a good idea.

On the other hand, if LDAP is second in order, it should find the property anyway, because it does not exist in the ZODB based properties.

So if order matters here, I suspect some kind of bug. Like the ZODB properties do not allow to cascade further down in the chain or something like this.

Thank you for your replies. I had a look at the acl_users/plugins/Properties Plugin and what I have listed in "Active Plugins" is:

pasldap
mutable_properties
auto_group

So it would appear to be in the right order. The author page will show the "location" attribute from ldap if the user has that defined in ldap so I thought I could use the same thing with the new fields I had added "mobile" and "phone":

                     <tal:location condition="authorinfo/location"
                                    i18n:translate="text_location">
                          Location:
                          <span tal:content="authorinfo/location"
                                tal:omit-tag=""
                                i18n:name="location">
                              Some location
                          </span>
                      </tal:location>

                      <tal:phone condition="authorinfo/phone"
                                    i18n:translate="text_phone">
                          Location:
                          <span tal:content="authorinfo/phone"
                                tal:omit-tag=""
                                i18n:name="phone">
                              Some phone
                          </span>
                      </tal:phone>

Is there anything else that needs to be done. I have tried rebuilding the catalog and restarting the server to make sure member data is not cached.

Author view gets the fields with the getMemberInfo method

which returns this:

        memberinfo = {
            'fullname': member.getProperty('fullname', ''),
            'description': member.getProperty('description', ''),
            'location': member.getProperty('location', ''),
            'language': member.getProperty('language', ''),
            'home_page': home_page,
            'username': member.getUserName(),
            'has_email': bool(member.getProperty('email')),
        }

I just modified that method adding to the dict:

'new_field': member.getProperty('new_field','')

You can also override author view and make new methods to retrieve that fields if you do not want to touch source code

Thank you csanahuja I have added those fields to the getMemberInfo method and now can display them on the author page.

Plone Foundation Code of Conduct