Perl能不能调用COM接口呢

Perl能不能调用COM接口呢

很好奇这个阿
顺便python可以么?
好像可以吧。
试试 Win32::OLE 模块。
显然可以,我曾经写过一个给IT用的。
[tips]使用perl通过adsi接口导出AD帐户列表,http://icylife.net/yunshu/show.php?id=535

[Copy to clipboard] [ - ]
CODE:
use warnings;
use strict;
use Win32::OLE;

use constant ADS_UF_ACCOUNTDISABLE => 2;
use constant ADS_SCOPE_SUBTREE => 2;

my $objConnection = Win32::OLE->new( "ADODB.Connection" );
my $objCommand = Win32::OLE->new( "ADODB.Command" );

# open ad
$objConnection -> open( "Provider=ADsDSOObject;" );

$objCommand -> = $objConnection;

# search what and how
$objCommand -> = "select userAccountControl,distinguishedName from 'GC://dc=china,dc=microsoft,dc=com' where objectCategory='user'";

# import all users
$objCommand -> Properties -> {"Page Size"} = 1000;
# search all subtree
$objCommand -> Properties -> = ADS_SCOPE_SUBTREE;

my $objRecordSet = Win32::OLE->new( "ADODB.Recordset" );
$objRecordSet = $objCommand->Execute( ) || die "query data from active directory error,exit\n";

while( not $objRecordSet -> eof )
{
    my $intUAC = $objRecordSet -> Fields("userAccountControl") -> value;
   
    # remove diable account
    if( not ( $intUAC & ADS_UF_ACCOUNTDISABLE ) )
    {
        my $longName = $objRecordSet -> Fields("distinguishedName") -> value;

        if( $longName =~ /^CN=([\w\.\-\_]+),/ )
        {
            print ."\n";
        }
    }
   
    $objRecordSet -> MoveNext();
}

谢谢各位哦