Assuming you are on an ActiveState Perl:
use strict;
use warnings;
#use Win32;
print 'I am ', Win32::LoginName, ' in domain ', Win32::DomainName, $/;
In addition to the informative thread marto referred to above,
which points to Win32::LoginName, knowing the domain
an accounts comes from might be of interest too, especially
in a bigger AD environment (forest).
Also note, that ActiveState's perl on Windows is
special, with regard to the Win32 module, insofar as it distinguishes between "[CORE]" functions and others.
Those [CORE] functions are available, even without a "use Win32;" (LoginName and DomainName among them).
More information on Win32 functions is available from
the cmd command line with perldoc Win32. |