Command-based auth failing but command works fine (LDAP)

I’m trying to set up LDAP authentication to the Home Assistant web page. To that end I’m using the command-based authentication provider.

Now, here’s the weird bit. In my attempts to debug the thing I’ve set up a new script so it just fires an ldapsearch command (with all the parameters already in the script, inc. username and password), and stores the results into a log file.

If I run the script from HA terminal or PUTTY then the command executes correctly. The log file contains the output as expected.

If I execute the script via the authentication provider (i.e. I try to log in using some generic values), it fails with a generic error User 'test' failed to authenticate, command exited with code 127 and the output log is blank. I know the script executes because if I delete the log file then a new one is created. But clearly, something weird is going on when the script is executed.

Below is the current setup for authentication providers. The s.sh script has the one, logged ldapsearch execution.

homeassistant:
  auth_providers:
    - type: homeassistant
    - type: command_line
      name: LDAPv1
      command: /bin/sh
#      args: ["/config/ldap-auth/ldap-auth.sh", "/config/ldap-auth/home-assistant.cfg"]
      args: ["/config/ldap-auth/s.sh"]
      meta: true

Any idea what’s causing this strange behavior?