我怎样才能从Perl的Active Directory的工作? [英] How can I work with Active Directory from Perl?

查看:183
本文介绍了我怎样才能从Perl的Active Directory的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑写一个与Active Directory进行交互的一些Perl脚本。作为有些新的Perl,我想知道是否有任何具体的模块,工具,技术等,任何人都建议我使用。截至目前,我只希望拉动用户信息来处理的脚本。

I am considering writing some Perl scripts that interact with Active Directory. Being somewhat new to Perl, I was wondering if there were any specific modules, tools, techniques, etc. that anyone would suggest I use. As of right now, I am only looking to pull user information to process with the script.

推荐答案

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;
}

这篇关于我怎样才能从Perl的Active Directory的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆