我正在考虑编写一些与 Active Directory 交互的 Perl 脚本。作为 Perl 的新手,我想知道是否有任何人会建议我使用的特定模块、工具、技术等。截至目前,我只想提取用户信息以使用脚本进行处理。
最佳答案
Active Directory的最佳来源example code in Perl is available here .来自 O'Reilly 的优秀 Active Directory Cookbook 的合著者 Robbie Allen .
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;
}
关于perl - 如何从 Perl 使用 Active Directory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1526028/