且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎样才能从Perl的Active Directory的工作?

更新时间:2023-08-17 21:30:52

Active Directory的例如code在Perl可以在这里找到。这是从罗比·艾伦的合着者O'Reilly的优秀 Active Directory的食谱

The best source of Active Directory example code in Perl is available here. It's from Robbie Allen, the co-author of O'Reilly's excellent Active Directory Cookbook.

下面是一个例子的从他们的食谱code:

Here is an example from their cookbook code:

# This Perl code finds all disabled user accounts in a domain.

# ---------------------------------------------------------------
# Adapted from VBScript code contained in the book:
#      "Active Directory Cookbook" by Robbie Allen
# ISBN: 0-596-00466-4
# ---------------------------------------------------------------

# ------ SCRIPT CONFIGURATION ------
my $strDomainDN = "<DomainDN>";    # e.g. dc=rallencorp,dc=com
# ------ END CONFIGURATION ---------
use Win32::OLE;
$Win32::OLE::Warn = 3;
my $strBase   =  "<LDAP://" . $strDomainDN . ">;";
my $strFilter = "(&(objectclass=user)(objectcategory=person)" . 
                "(useraccountcontrol:1.2.840.113556.1.4.803:=2));";
my $strAttrs  = "name;";
my $strScope  = "subtree";

my $objConn = Win32::OLE->CreateObject("ADODB.Connection");
$objConn->{Provider} = "ADsDSOObject";
$objConn->Open;
my $objRS = $objConn->Execute($strBase . $strFilter . $strAttrs . $strScope);
$objRS->MoveFirst;
while (not $objRS->EOF) {
    print $objRS->Fields(0)->Value,"\n";
    $objRS->MoveNext;
}