我正在考虑编写一些与Active Directory交互的Perl脚本。对于Perl来说有点新,我想知道是否有任何人建议我使用的特定模块,工具,技术等。截至目前,我只想提取用户信息来处理脚本。
答案 0 :(得分:6)
Active Directory example code in Perl is available here的最佳来源。它来自罗比艾伦,他是奥莱利出色的Active Directory Cookbook的合着者。
Here is an example来自他们的食谱代码:
# 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;
}
答案 1 :(得分:1)
据我了解,有两种选择:
我对Win32 :: Ole没有多少经验,可能是其他人可以详细说明一下。