in reply to Remote Server Types

In the hash %info returned by Win32::Lanman::NetServerGetInfo($server, \%info, 1) there is a key 'type' that has a numeric value. This is a 32-bit bitstring, the bits of which denote the various types of server. These bits can be decoded by ANDing with the SV_TYPE_* constants that are exported by the module.

This script demonstrates how to get at the info. It a shame that the module doesn't export the vast array of constants as a hash in the first place, it would make using them a whole lot easier:)

#! perl -slw use strict; use Win32::Lanman; my %serverType = ( SV_TYPE_AFP => SV_TYPE_AFP, SV_TYPE_ALL => SV_TYPE_ALL, SV_TYPE_ALTERNATE_XPORT => SV_TYPE_ALTERNATE_XPORT, SV_TYPE_BACKUP_BROWSER => SV_TYPE_BACKUP_BROWSER, SV_TYPE_CLUSTER_NT => SV_TYPE_CLUSTER_NT, SV_TYPE_DCE => SV_TYPE_DCE, SV_TYPE_DFS => SV_TYPE_DFS, SV_TYPE_DIALIN_SERVER => SV_TYPE_DIALIN_SERVER, SV_TYPE_DOMAIN_BAKCTRL => SV_TYPE_DOMAIN_BAKCTRL, SV_TYPE_DOMAIN_CTRL => SV_TYPE_DOMAIN_CTRL, SV_TYPE_DOMAIN_ENUM => SV_TYPE_DOMAIN_ENUM, SV_TYPE_DOMAIN_MASTER => SV_TYPE_DOMAIN_MASTER, SV_TYPE_DOMAIN_MEMBER => SV_TYPE_DOMAIN_MEMBER, SV_TYPE_LOCAL_LIST_ONLY => SV_TYPE_LOCAL_LIST_ONLY, SV_TYPE_MASTER_BROWSER => SV_TYPE_MASTER_BROWSER, SV_TYPE_NOVELL => SV_TYPE_NOVELL, SV_TYPE_NT => SV_TYPE_NT, SV_TYPE_POTENTIAL_BROWSER => SV_TYPE_POTENTIAL_BROWSER, SV_TYPE_PRINTQ_SERVER => SV_TYPE_PRINTQ_SERVER, SV_TYPE_SERVER => SV_TYPE_SERVER, SV_TYPE_SERVER_MFPN => SV_TYPE_SERVER_MFPN, SV_TYPE_SERVER_NT => SV_TYPE_SERVER_NT, SV_TYPE_SERVER_OSF => SV_TYPE_SERVER_OSF, SV_TYPE_SERVER_UNIX => SV_TYPE_SERVER_UNIX, SV_TYPE_SERVER_VMS => SV_TYPE_SERVER_VMS, SV_TYPE_SQLSERVER => SV_TYPE_SQLSERVER, SV_TYPE_TERMINALSERVER => SV_TYPE_TERMINALSERVER, SV_TYPE_TIME_SOURCE => SV_TYPE_TIME_SOURCE, SV_TYPE_WFW => SV_TYPE_WFW, SV_TYPE_WINDOWS => SV_TYPE_WINDOWS, SV_TYPE_WORKSTATION => SV_TYPE_WORKSTATION, SV_TYPE_XENIX_SERVER => SV_TYPE_XENIX_SERVER, ); my $serverName = '\\\\YourServerName'; my %info; if( Win32::Lanman::NetServerGetInfo( $serverName, \%info, 1 ) ) { for( keys %serverType ) { print "$serverName is a $_" if $info{type} & $serverType{$_}; } } else { print "NetServerGetInfo error:$^E"; }

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller