check group name in ldap result (#150)

This commit is contained in:
Vladimir Sukhonosov 2023-09-28 01:52:30 +03:00 committed by GitHub
parent 8f32f9ae11
commit 0c4d21f204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,10 +88,10 @@ class Plugin(BaseAuthService):
base=self.__base,
scope=ldap.SCOPE_SUBTREE,
filterstr=f"(&(objectClass=user)(userPrincipalName={user})(memberOf={self.__group}))",
attrlist=["userPrincipalName", "memberOf"],
attrlist=["memberOf"],
timeout=self.__timeout,
) or []):
if dn is not None and isinstance(attrs, dict) and attrs.get("memberOf"):
if dn is not None and isinstance(attrs, dict) and self.__group.encode() in attrs.get("memberOf"): # type: ignore
return True
except ldap.INVALID_CREDENTIALS:
pass