Skip to content

Commit

Permalink
Merge pull request #32 from dignajar/bugfixes/fix-regex-and-search-cn
Browse files Browse the repository at this point in the history
Fix regex
  • Loading branch information
dignajar authored Jun 18, 2021
2 parents 6e53544 + 961f8e5 commit 0d4e9de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions files/aldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def __decode__(self, word:bytes) -> str:
return word.decode("utf-8")

def __findMatch__(self, group:str, adGroup:str):
# Extract the Common Name from the string (letters, spaces, underscores and hyphens)
adGroup = re.match('(?i)CN=((\w*\s?_?-?)*)', adGroup).group(1)
try:
# Extract the Common Name from the string (letters, spaces, underscores and hyphens)
adGroup = re.search('(?i)CN=((\w*\s?_?-?)*)', adGroup).group(1)
except Exception as e:
self.logs.warning({'message':'There was an error trying to search CN: %s' % e})
return None

# Disable case sensitive
if not self.groupCaseSensitive:
Expand Down
8 changes: 6 additions & 2 deletions files/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ def validateUser(self, username:str, password:str) -> bool:
return False

def __findMatch__(self, group:str, adGroup:str):
# Extract the Common Name from the string (letters, spaces, underscores and hyphens)
adGroup = re.match('(?i)CN=((\w*\s?_?-?)*)', adGroup).group(1)
try:
# Extract the Common Name from the string (letters, spaces, underscores and hyphens)
adGroup = re.search('(?i)CN=((\w*\s?_?-?)*)', adGroup).group(1)
except Exception as e:
self.logs.warning({'message':'There was an error trying to search CN: %s' % e})
return None

# Disable case sensitive
if not self.groupCaseSensitive:
Expand Down

0 comments on commit 0d4e9de

Please sign in to comment.