[GH-ISSUE #29] Groups lookup fails if a single match doesn't have the regular expression match #6

Closed
opened 2026-03-02 03:44:33 +03:00 by kerem · 4 comments
Owner

Originally created by @aakarshg on GitHub (Jun 15, 2021).
Original GitHub issue: https://github.com/dignajar/another-ldap-auth/issues/29

Let's take an example of a group as follows :

ipaUniqueID=blahblah-blah,cn=sudorules,cn=sudo,dc=blah,dc=net

When the search hits this particular group it will crash due to an AttributeError as the code doesn't handle it and not try to process the next set of groups. The error looks something like this:

  File "/home/aldap/main.py", line 200, in login
    validGroups, matchedGroups = cache.validateGroups(username, matchingGroups)
  File "/home/aldap/cache.py", line 98, in validateGroups
    matches = list(filter(None,list(map(self.__findMatch__, repeat(group), adGroups))))
  File "/home/aldap/cache.py", line 73, in __findMatch__
    adGroup = re.match('(?i)CN=((\w*\s?_?-?)*)', adGroup).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
Originally created by @aakarshg on GitHub (Jun 15, 2021). Original GitHub issue: https://github.com/dignajar/another-ldap-auth/issues/29 Let's take an example of a group as follows : ``` ipaUniqueID=blahblah-blah,cn=sudorules,cn=sudo,dc=blah,dc=net ``` When the search hits this particular group it will crash due to an `AttributeError` as the code doesn't handle it and not try to process the next set of groups. The error looks something like this: ``` File "/home/aldap/main.py", line 200, in login validGroups, matchedGroups = cache.validateGroups(username, matchingGroups) File "/home/aldap/cache.py", line 98, in validateGroups matches = list(filter(None,list(map(self.__findMatch__, repeat(group), adGroups)))) File "/home/aldap/cache.py", line 73, in __findMatch__ adGroup = re.match('(?i)CN=((\w*\s?_?-?)*)', adGroup).group(1) AttributeError: 'NoneType' object has no attribute 'group' ```
kerem 2026-03-02 03:44:33 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@aakarshg commented on GitHub (Jun 15, 2021):

I've a fix incoming for this.. will be opening a PR shortly

<!-- gh-comment-id:861771809 --> @aakarshg commented on GitHub (Jun 15, 2021): I've a fix incoming for this.. will be opening a PR shortly
Author
Owner

@dignajar commented on GitHub (Jun 16, 2021):

Why that structure for groups ?

For LDAP the groups are composed like this:

memberof=CN=YourGroup,....
<!-- gh-comment-id:862184616 --> @dignajar commented on GitHub (Jun 16, 2021): Why that structure for groups ? For LDAP the groups are composed like this: ``` memberof=CN=YourGroup,.... ```
Author
Owner

@aakarshg commented on GitHub (Jun 17, 2021):

Freeipa does it like that 😓

<!-- gh-comment-id:863346193 --> @aakarshg commented on GitHub (Jun 17, 2021): Freeipa does it like that :sweat:
Author
Owner

@dignajar commented on GitHub (Jun 22, 2021):

Fixed in the new version. thank you!

<!-- gh-comment-id:865771336 --> @dignajar commented on GitHub (Jun 22, 2021): Fixed in the new version. thank you!
Sign in to join this conversation.
No labels
bug
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/another-ldap-auth#6
No description provided.