jjohn has asked for the wisdom of the Perl Monks concerning the following question:
Greetings,
I'm having some difficulty calling the Win32 API function CoInitializeSecurity() from Perl. I'm using ActiveState Perl 5.8.3 and the Win32::API module. The COM objects I need to talk to require impersonation and, according to the docs, I can do this with the aforementioned function. However, translating the C/VB docs into a Win32::API call has proven a bit beyond my humble powers. Has anyone successfully called this OLE32.DLL function successfully from Perl? My target platform is Server 2003, but this function is available on earlier platforms.
Here's my sloppy test harness:
use strict; use Data::Dumper; use Win32::API; print "Setting COM security\n"; # CoInitilizeSecurity defined : # http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com +/htm/cmf_a2c_8ayh.asp my $CoInit = Win32::API->new( "OLE32.DLL", "CoInitializeSecurity" # input prototypes # 1 P, # Access perms # 2 N, # num of els in asAuthSvr # 3 P, # array of auth services # 4 P, # reserved # 5 N, # default auth level # 6 N, # proxy impersonation level # 7 P, # sole auth list # 8 N, # add'l capabilities # 9 P, # reserved "PNPPNNPNP", "N", # return ) or warn "Can't get DLL"; my $NULL = 0; my $RPC_C_AUTHEN_NONE = 0; my $RPC_C_AUTHEN_LEVEL_NONE = 1; my $RPC_C_IMP_LEVEL_IMP = 3; my $EOAC_NONE = 0; my $result = $CoInit->Call( $NULL, 0, $RPC_C_AUTHEN_NONE, $NULL, $RPC_C_AUTHEN_LEVEL_NONE, $RPC_C_IMP_LEVEL_IMP, $NULL, $EOAC_NONE, $NULL, ); # $result = -2147221008 if ($result != 0){ warn "Oops: ", Dumper($result), "\n"; } print "done\n";
Also note that I have tried Win32::API::Prototype but it fails to translate the return argument and the first parameter. Any suggestions as to how I might crack this nut would be met with warm appreciation.
Thank you for your time.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling CoInitializeSecurity() from Win32::API
by meetraz (Hermit) on Feb 21, 2004 at 00:25 UTC | |
by jjohn (Beadle) on Feb 22, 2004 at 19:17 UTC |