Active Directory LDAP connection with mail or userPrincipalName

Active Directory LDAP connection with mail or userPrincipalName

Hello community,

I have set up a user filter with a group and sAMAccountName.

(&(memberof=cn=SERVICE_Users,ou=Groupes,ou=RIRI,dc=fifi,dc=intra)(sAMAccountName=%s))
No worries it works.

I want to add the possibility of mail
(&(memberof=cn=SERVICE_Users,ou=Groupes,ou=RIRI,dc=fifi,dc=intra)(|(sAMAccountName=%s)(mail=%s)))
I can connect with sAMAccountName but not with mail

While searching the net I came across a link but it is from 2019 and does not contain an answer