METHOD 1. If you can't get samba to do it, install Fail2Ban -- a log file monitoring and security suite (packages available through most Linux distributions software management systems) -- and then configure Fail2Ban to watch the samba log for the login lines, set the number of lines to detect to 1 and set the action to a script that will do whatever it is you want done on login. To accomplish all of this you will need to edit files under /etc/fail2ban and be familiar with regular expressions and the log files you need to watch.
This won't be as clean as a script integrated with samba. For instance, it probably won't be synchronised to the exact moment of user login.
METHOD 2. Again, not as clean, as we'd like. Configure your samba to spit out a log file for each connection. Make directories called "unprocessed" and "processed" and configure samba to dump the per-connection log file to the "unprocessed" directory. Write a cron job or a looping script (sleep 1 or 2 seconds between iterations, perhaps) to loop through the files in the unprocessed directory and do whatever you need done, then mv them to the processed directory.
Possibly if you describe exactly what you want to do in more detail, other people can help you.