Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import/export group mappings #30

Merged
merged 5 commits into from
Sep 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ Changelog

- Drop support for Plone 4.1.
[hvelarde]
- Fix plugin activation for AD; correctly add mandatory schema items; activate
group management plugin for non-AD (to allow modifying group memberships via
Plone).
[adaugherity]
- Properly store settings made via control panel so that the control panel,
ZMI, and portal_setup export all show the same data. Added some more fields
to portal_setup import/export, including extra_user_filter, group mappings,
and plugin type (AD/non-AD).
[adaugherity]
- Misc. minor bugfixes and documentation improvements.
[adaugherity]


1.3.2 (2015-03-02)
Expand Down
25 changes: 16 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@ Plone can use both users and groups from an Active Directory system. Writing
to Active Directory is not supported.

With Active Directory you can use two different properties as login name:
`userPrincipalName` and `sAMAccountName`. `sAMAccountName` is the plain account
name without any domain information and is only unique within a single domain.
If your environment only uses a single AD domain this option is the best
choice. For environments with multiple names the `userPrincipalName` attribute
can be used since this includes both account name and domain information.

``userPrincipalName`` and ``sAMAccountName``. ``sAMAccountName`` is the plain
account name without any domain information and is only unique within a single
domain. If your environment only uses a single AD domain this option is the
best choice. For environments with multiple names the ``userPrincipalName``
attribute can be used since this includes both account name and domain
information.

Since Plone does not support binary user ids it is not possible to use the
`objectGUID` attribute as user ids. Instead you can use either `sAMAccountName`
or `userPrincipalName`. The same criteria for choosing a login name also
apply to selecting the user id attribute.
``objectGUID`` attribute as user ids. Instead you can use either
``sAMAccountName`` or ``userPrincipalName``. The same criteria for choosing a
login name also apply to selecting the user id attribute.

Newer versions of Active Directory may also work using the standard LDAP
plugin, which supports limited writing to AD, including modifying group
memberships. If your group objects have ``member`` attributes containing the
user's full DN, the standard LDAP plugin should work for you. Note that this
will not support nested groups.


Standard LDAP
-------------
Expand Down
4 changes: 4 additions & 0 deletions plone/app/ldap/engine/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class LDAPConfiguration(OrderedContainer):
group_scope = SCOPE_SUBTREE
password_encryption = "crypt"
default_user_roles = "Member"
extra_user_filter = ""
local_groups = False
implicit_mapping = False
group_mappings = {}
read_only = False
activated_plugins = []
cache = ''
Expand Down
16 changes: 16 additions & 0 deletions plone/app/ldap/ploneldap/exportimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from xml.dom.minidom import parseString
from zope.component import getUtility
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
import ast
import logging

ldap_props = ['_login_attr',
Expand All @@ -19,6 +20,7 @@
'users_scope',
'_local_groups',
'_implicit_mapping',
'_groups_mappings',
'groups_base',
'groups_scope',
'_binduid',
Expand Down Expand Up @@ -128,6 +130,7 @@ def importData(self, context, out):
def extractData(self, root, pas, out):
plug_id = str(root.getAttribute('id'))
update = root.getAttribute('update') == 'True'
meta_type = root.getAttribute('meta_type')

settings = {}
interfaces = []
Expand Down Expand Up @@ -234,6 +237,12 @@ def extractData(self, root, pas, out):

# base configuration
config = getUtility(ILDAPConfiguration)
if meta_type in [u"Plone Active Directory plugin",
u"ActiveDirectory Multi Plugin"]:
config.ldap_type = u"AD"
else:
config.ldap_type = u"LDAP"

config.login_attribute = settings['_login_attr']
config.userid_attribute = settings['_uid_attr']
config.rdn_attribute = settings['_rdnattr']
Expand All @@ -244,8 +253,15 @@ def extractData(self, root, pas, out):
config.bind_dn = settings['_binduid']
config.bind_password = settings['_bindpwd']
config.user_object_classes = ','.join(settings['_user_objclasses'])
config.extra_user_filter = settings['_extra_user_filter']
config.password_encryption = settings['_pwd_encryption']
config.default_user_roles = ','.join(settings['_roles'])
config.implicit_mapping = settings['_implicit_mapping']
config.local_groups = settings['_local_groups']
try:
config.group_mappings = ast.literal_eval(settings['_groups_mappings'])
except (ValueError, SyntaxError, KeyError):
config.group_mappings = {}
config.read_only = settings['read_only']
config.activated_plugins = interfaces
config.cache = cache
Expand Down
5 changes: 5 additions & 0 deletions plone/app/ldap/ploneldap/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def createLDAPPlugin(id="ldap-plugin"):
bindpwd=config.bind_password or "",
encryption=config.password_encryption,
roles=config.default_user_roles or "",
local_groups=config.local_groups,
read_only=config.read_only,
obj_classes=config.user_object_classes)

Expand All @@ -86,6 +87,10 @@ def createLDAPPlugin(id="ldap-plugin"):
directlyProvides(plugin, IManagedLDAPPlugin)
enablePASInterfaces()
enableCaching(config.cache)
luf=plugin._getLDAPUserFolder()
luf.manage_changeProperty('_extra_user_filter', config.extra_user_filter)
luf.manage_changeProperty('_implicit_mapping', config.implicit_mapping)
luf.manage_changeProperty('_groups_mappings', config.group_mappings)


def configureLDAPServers():
Expand Down