GetInfoEx (Perl)

This code can be found in Chapter 21 of Active Directory, 3rd Edition

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Perl code from this site.

# From the book "Active Directory, Third Edition" 
# ISBN: 0-596-10173-2

use Win32::OLE;
use constant vbTab => "\x09";

my $objUser;
# An ADSI user object
my $arrProps;
# An array of properties to return

$objUser = Win32::OLE->GetObject('LDAP://cn=administrator,cn=Users,dc=mycorp,dc=com');

# **********************************************************************
# Set the list of properties to return
# **********************************************************************
$arrProps = ['cn', 'ADsPath'];

# **********************************************************************
# Get the specified properties
# **********************************************************************
$objUser->GetInfoEx($arrProps, 0);

print $objUser->cn . vbTab . $objUser->ADsPath, "\n";

This code has been viewed 1093 times.

New from the creators of TechTasks.com: StatSheet.com