如何使用Perl的Active Directory?

我正在考虑编写一些与Active Directory交互的Perl脚本.对于Perl来说有点新,我想知道是否有任何人建议我使用的特定模块,工具,技术等.截至目前,我只想提取用户信息来处理脚本.

解决方法

Active Directory example code in Perl is available here的最佳来源.它来自Robbie Allen,O’Reilly出色的 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. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...