Tag Archives: Perl

Semisynchronous WMI

Experimenting with querying WMI from Perl with Win32::OLE, I ran across the following WMI query options in an Perl example from Microsoft’s Script Center:

$colItems = $objWMIService->ExecQuery ("SELECT * FROM Win32_Share","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly); 

After some digging, I found the following explanation of those options wbemFlagReturnImmediately, and wbemFlagForwardOnly:

Because WMI manages the object, semisynchronous mode is more secure than asynchronous mode. However, if you use semisynchronous mode with more than 1,000 instances, instance retrieval can monopolize the available resources, which can degrade the performance of the program or script and the computer using the program or script. Each object takes up the necessary resources until the memory is released.

To work around this condition, you can call the method with the iFlags parameter set with the wbemFlagForwardOnly and wbemFlagReturnImmediately flags to instruct WMI to return a forward-only SWbemObjectSet. A forward-only SWbemObjectSet eliminates the performance problem caused by a large data set by releasing the memory after the object is enumerated.

[from: http://msdn.microsoft.com/en-us/library/aa384832(v=vs.85).aspx ]

I wanted to put this somewhere, because I’m sure I’ll forget.

Compiling OpenSSL for Win x64

I’m upgrading the components of the user provisioning system I built. Previously, I used ActiveState Perl and the UWinnipeg PPM repository to get the Net::LDAPS stack working.

This time, though, I decided I wanted to use the native architecture of my Server 2008 R2 systems. I am using the Perl64 install from ActiveState, but I have to build my own SSL libraries (and maybe roll up PPMs for the needed perl mods).

I just compiled OpenSSL for x64 (amd64), mostly following the instructions in the INSTALL.W64 and INSTALL.W32 documents. I’m blogging the step for my future reference:

  1. Open a VS x64 Win64 Command Prompt and navigate to the source directory
  2. perl Configure VC-WIN64A –prefix=c:\local\openssl
  3. ms\do_win64a.bat
  4. nmake -f ms\ntdll.mak
  5. nmake -f ms\ntdll.mak test (all tests passed)
  6. nmake -f ms\ntdll.mak install

Running the openssl command succeeds:

C:\local\openssl\bin>openssl version 
  
OpenSSL 1.0.0a 1 Jun 2010

Wednesday – April 22

I’ve been working on revising and refactoring a Perl application that I wrote about four years ago to handle our domain account provisioning. Originally, it was a monolithic application, running on ActiveState Perl. Now it needs to run on a Windows Server 2008 x64 host. I use a couple of additional modules that are available from the excellent repository at UWinnipeg that include some compiled code. Rather than run the Perl64 version, and then having to compile my own DLLs, I decided to just install the 32-bit version of Perl, and continue using the modules.

The application is feature-complete, I believe, and is ready to be tried in production. When I attempted to run it under a service account, though, I encountered an error that I hadn’t received running it under my working account. I could repro the error with a simple one-liner:

C:\Perl\bin>perl -MNet::SSLeay
Can’t load ‘C:/Perl/site/lib/auto/Net/SSLeay/SSLeay.dll’ for module Net::SSLeay:
load_file:Access is denied at C:/Perl/lib/DynaLoader.pm line 202.
at – line 0
Compilation failed in require.
BEGIN failed–compilation aborted.

I checked my PATH, and verified rights to the file indicated. Things were in order and I was stumped. Some google searches turned up advice to check my PATH variable and confirm permissions. OK.

I used Process Monitor from SysInternals and filtered on the perl command line. Toward the end I found a couple lines indicating ACCESS DENIED to C:\Perl\bin\libeay32.dll.

procmon-perl-libeay32

Now this is not the file that was mentioned in the error, but I checked this one, and the SSLeay.dll that was there, too, and wouldn’t you know? They had different ACLs than the rest of the files. Perhaps the ppm installer didn’t assign the rights when it installed them? Whatever. I granted the service account appropriate access and that fixed the problem.

Huzzah!

Wednesday – March 25

Fixed permissions early (6 am) successfully with NetApp fsecurity command. That and the secedit tool made it quick work.

Did a little Russinovich-guided analysis of a minidump file created by EMC Networker.

Did some more work on UVM::AD module.

A number of other accumulated general administration tasks.

Wrote this perl one-liner to find the volume that contains a user’s homedir:

Z:\>perl -e"foreach (1..5) { $dir=qq{uvol_t1_$_\$}; print $dir, qq{\n} if ( -d '\\\\files\\' . $dir . '\\q-home\\g\\gduke'); }

might be worth turning that into a more robust command and turning it into an exe.

Horror! It appears that I forgot my laptop’s power supply at work. A wrinkle in the work-from-home-during-teacher-conference-early-release-days plan. [/sigh]

Monday – March 23

Goal for today: finish moving provisioning.

Made some initial progress on separating functionality into different modules. Lots of reading about modules, semantics of use and require. I should probably be creating tests at the same time. Will this ever get done?!

Friday – The 13th of March

Thirteen is a lucky number!

Found the UVM Webteam’s official style guide. Nice level of detail.

Installed WinSCP to help a user, then a Windows 7 update. My system rebooted and was unresponsive. After trying several different things, I ended up booting into safe mode and removing WinSCP. Whatever!

Get together with Greg to review his home migration script-fu.

Completed initial provisioning of new homedir q-trees, including quotas and cifs homedir configs.

Looks like I can run 32-bit Perl on 64-bit Windows. It appears that the various packages I used from the theory.uwinnipeg.ca ppm repository are there for Perl 5.10, so I’ll go ahead and use that.

A couple small administrivia requests peppered throughout the day.

Monday – March 9

Because of my body’s resistance to the artificial manipulation of time zones, I’m running at about ¾-impulse.

Happy Birthday to my little sister.

A friend pointed out to me that Tax Day is also Same Sex Kiss Day, to be held at your friendly neighborhood Starbucks, or wherever you want, really.

On the list for today: storage management, server disk repartitioning, and group management training.

Updating Tools list.

Configuring new SharePoint servers’ backup.

Working with server disk management; accessing system via remote console, mounting ISO as virtual CD across the wire.

Greg showed me WinDirStat. I’ve seen it in several magazines, but never quite grokked the utility of the rectilinear representations of files. Now I understand, and it makes a lot of sense. It would be nice to be able to select alternate color schemes.

Using GPartEd Live to fiddle with partitions. An hour or so later, and the drives have been resized and Windows is up and running, with no problems. Phew!

Sent Marty documentation about backing up MS SQL Server Express Edition using SQLCMD.EXE and Scheduled Tasks.

Investigate account issue for Beth.

Touch base  with Daryl on group management issue for CS.

UWinnipeg has ActivePerl 5.10 packages for IO-Socket-SSL. Is it enough?

Thursday – March 5

Goal for today: get auto_provisioning script working.

Feeling cold; AC is blowing strong and winning the HVAC smackdown.

Made lots of progress on provisioning scripts, then hit brick wall: Need IO::Socket::SSL and Net::SSLeay in order to do Net::LDAP->starttls, and the perldap package from UWinnipeg for Perl 5.10 doesn’t have these available.

Do I try to compile myself and build PPMs? Ugh.

Maybe ActivePerl 5.8 x64 would get the job done…