Executing script from specific job server via API call

We have created a LDAP search script which we want use via API call.
Now this script works fine if we test it from Designer in customer job server environment.
If we test it over API call or Designer then it always throws error that server is not operational. We can understand because LDAP in customer environment.

Requirement is : Whenever we call this script from API call then script always should be executed from customer job server only.

We can not create process for it as it is runtime and we need it directly via script.

Thanks