'Working on a large application on Windows that uses the Win32::Lanman module. On XP, 2003, and 2007, the code works as written. On Win2008R2, it doesn't. We haven't tested on a huge number of machines, so I'm not sure the OS version is relevant. Maybe? Maybe not?
Anyway, in the main application the problem code looks like:
-----------------
unless (Win32::Lanman::NetLocalGroupEnum('', \@arrayOfHashes))
{
my $error = Win32::FormatMessage Win32::Lanman::GetLastError;
$error = Win32::Lanman::GetLastError if ($error eq "");
throw Error::Simple($error);
}
-----------------
We're hoping @arrayOfHashes would contain an array of groups on the machine. It doesn't and we get an error "The specified procedure could not be found."
I initially thought there was something wrong with Win32::Lanman or how we were using it. So, I wrote a little test like these:
-----------------
package getGroups;
use strict;
use Win32::Lanman;
sub getGroupsViaLanman {
my $arrayRef = shift;
if (Win32::Lanman::NetLocalGroupEnum('', $arrayRef)){
print "Package Array: " . Dumper($arrayRef) . "\n";
return $arrayRef;
}
else {
my $error = Win32::Lanman::GetLastError();
print "ERROR: failed to get groups via Win32::Lanman::NetLocalGro
+upsEnum ---> " . Win32::FormatMessage Win32::Lanman::GetLastError()
+. "\n";
exit;
}
}
1;
-----------------
and
-----------------
#!perl
use strict;
use getGroups;
my @results;
getGroups::getGroupsViaLanman(\@results);
use Data::Dumper;
print "GROUPS: " . Dumper(@results) . "\n";
-----------------
That works. So, Win32::Lanman and the general approach to using it work. Ergo, we must be doing something in our larger application that is stepping on something that Win32::Lanman is using.
I copied that last chunk of code into our main application, replacing the previous version and the problem persists. So, my call to Win32::Lanman::NetLocalGroupsEnum works in my trivial test and fails when the same code (verbatim) is used in the main application.
How do I figure out what that is without resorting to a brute force exercise of reviewing code, printing voluminous debug, and .... divide and conquer?
I generally live in a Linux/UNIX world. This is happening on a 64bit Windows machine. Could the 64 vs 32 bit wrinkles in windows (e.g. view of registries and such) effect this?
...'Heading off to start dissecting Win32::Lanman...