code: def authenticate(self, username, password):
          
  
          if username is None or password is None:
              return False
  
          # check the username
          if not re.match("^[A-Za-z0-9_-]*$", username):
              return False
  
          user_dn = self.get_user_dn(username)
  
          server = ldap3.Server(
                  self.uri,
                  use_ssl=self.use_ssl
              )
  
          connection = ldap3.Connection(server, user=user_dn, password=password)
  
          return connection.bind()
docs: Authenticate the user with a bind on the LDAP server