Untitled

Anonymous
Plain Text
09/10/2025 9:46 AM
1.2 KB
17
Indexable
Never
    ldap_plugin = acl_users.get('pasldap')
    if ldap_plugin:
        ldap_users = ldap_plugin.enumerateUsers(
            id=None,
            exact_match=False,
            attributes=['cn', 'mail', 'distinguishedName']
        )
        for ldap_user in ldap_users:
            user_id = ldap_user.get('id')
            ldap_user_ids.add(user_id)

            # try to get Plone properties if user exists in source_users
            local_plugin = acl_users.get('source_users')
            cargo = ''
            telefono = ''
            if local_plugin:
                local_user = local_plugin.getUserById(user_id)
                if local_user:
                    cargo = getattr(local_user, 'cargo', '')
                    telefono = getattr(local_user, 'telefono', '')

            all_users.append({
                'id': user_id,
                'fullname': ldap_user.get('cn', ''),
                'email': ldap_user.get('mail', ''),
                'area': ldap_user.get('distinguishedName', ''),
                'cargo': cargo,
                'telefono': telefono,
                'pluginid': 'pasldap',
                'portrait': f'/++api++/portrait/{user_id}',
            })
Editor is loading...
Leave a Comment