Skip to content

Commit

Permalink
Fix regex
Browse files Browse the repository at this point in the history
  • Loading branch information
dignajar committed Jun 18, 2021
1 parent 6e53544 commit 961f8e5
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 961f8e5

Please sign in to comment.