"Events and Messages : Proactive" - Only allow SAP users to download SAP-documents
Event in zFTPServer:
BeforeDownload
Script in zFTPServer:
C:\Scripts\BusinessUser.bat %USERNAME% "%LOCAL_FILENAME%"
Error message in zFTPServer:
Access denied
Contents of file "C:\Scripts\BusinessUser.bat":
@echo off
rem Extract file information and remove quotes
set FILE=%2
for /f "useback tokens=*" %%a in ('%FILE%') do set FILE=%%~a
rem Allow access if not SAP document
if /I not "%FILE:~0,17%" == "C:\SAP Documents\" exit 0
rem Search for current user in the SAP database, we can ignore SQL injections since the user has logged in correctly
osql -d <database> -U <user> -P <pass> -Q "select 'ACCESS OK' from OUSR where USER_CODE='%1'" | find "ACCESS OK" >NUL
rem Deny access if user not in SAP database
if ERRORLEVEL 1 exit 1
rem All is OK
exit 0