Check fuction call counter properly.
If normal authentication fails and a PAM service is defined, PAM authentication is attempted. Separate services can be set for read-only users and admin-level users.
The same code can be used for REST-API authentication.