Reputation: 504
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.
Upvotes: 4
Views: 6222
Reputation: 13485
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.
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;
}
Upvotes: 6
Reputation: 11421
From what I understand, there are two options:
I don't have much experience with Win32::Ole, may be someone else can elaborate on that a bit.
Upvotes: 1