I'm trying to re-code some Perl script I have to Python (and extend it). With Perl, using the Net library, I can give a hostname and get the Windows username. Here is a snippet of Perl code:
my $NetBios = Net::NBName->new;
my $nbName = $NetBios->node_status($hostname);
if ( $nbName ) {
if ( $nbName->as_string =~ /^(\S+)\s+/ ) {
($user = $1) =~ tr/A-Z/a-z/;
}
}
I'd like to do the same thing in Python, but I cannot seem to find the right library to do this. Is there an equivalent way?
For the background, I get the hostname of the user that is connected to a terminal server port. From that, if the hostname has "dhcp" or "vpn" in it, I want to use NetBIOS and try to get the username for that system (likely a PC).