Last active
November 29, 2016 13:55
-
-
Save witsch/bc2de8308d4a2cc72aedeb60058177f2 to your computer and use it in GitHub Desktop.
posixGroups support for Plone/Zope's `Products.LDAPUserFolder` (2.27)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Products/LDAPUserFolder/LDAPUserFolder.py b/Products/LDAPUserFolder/LDAPUserFolder.py | |
index 8402da3..60f9634 100644 | |
--- Products/LDAPUserFolder/LDAPUserFolder.py | |
+++ Products/LDAPUserFolder/LDAPUserFolder.py | |
@@ -19,6 +19,7 @@ $Id$ | |
import logging | |
import os | |
import random | |
+import re | |
try: | |
from hashlib import sha1 as sha_new | |
except ImportError: | |
@@ -962,7 +963,10 @@ class LDAPUserFolder(BasicUserFolder): | |
for dn in all_dns.keys(): | |
try: | |
- user = self.getUserByDN(to_utf8(dn)) | |
+ if 'uid=' in dn: | |
+ user = self.getUserByDN(to_utf8(dn)) | |
+ else: | |
+ user = self.getUser(dn) | |
except: | |
user = None | |
@@ -1228,6 +1232,8 @@ class LDAPUserFolder(BasicUserFolder): | |
group_filter = '(|' | |
for g_name, m_name in GROUP_MEMBER_MAP.items(): | |
+ if g_name == 'posixGroup': | |
+ dn, = re.search(r'uid=([^,]*),', dn).groups() | |
fltr = filter_format(f_template, (g_name, m_name, dn)) | |
group_filter += fltr | |
diff --git a/Products/LDAPUserFolder/utils.py b/Products/LDAPUserFolder/utils.py | |
index 83d6f95..f6de93f 100644 | |
--- Products/LDAPUserFolder/utils.py | |
+++ Products/LDAPUserFolder/utils.py | |
@@ -47,6 +47,7 @@ GROUP_MEMBER_MAP = { 'groupOfUniqueNames' : 'uniqueMember' | |
, 'accessGroup' : 'member' | |
, 'group' : 'member' | |
, 'univentionGroup' : 'uniqueMember' | |
+ , 'posixGroup' : 'memberUid' | |
} | |
GROUP_MEMBER_ATTRIBUTES = Set(list(GROUP_MEMBER_MAP.values())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an updated version of David's patch as suggested in his Plone/Zope: Using LDAPUserFolder with posixGroups blog post.
The original patch has been working quite nicely for us for a couple of years. So thank you David! :)
However, once your user base does not exactly match the remainder of the user's DNs, e.g. when your users are organized hierarchically (and you're using a "subtree" scope to find them) simply adding
self.users_base
no longer works. The above version should do the trick...