Linux Active Directory User Authentication Check

Version 1

    Disclaimer: I'm not fluent in writing perl scripts and this is my first one so there may be better ways to write this script and if someone knows a better way leave it in the comment and I will update. I have verified this script works and currently use it.

    This perl script is used to verify user authentication against Active Directory (AD) is working correctly between a Linux box and AD. We use AD authentication for SFTP access on one of our boxes and for some reason it fails so I created this monitor to alert when it happens so we can dig in and find out the cause. The current fix is to restart winbind and samba but still looking for the smoking gun.

     

    To use change "uname" on the line "my $uname = `id uname`;" to a valid AD user. For example if a valid user is jmama then the line would read "my $uname = `id jmama`;" minus the double quotes but leave the `s.