Example2 (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;

my $objGroup;
# An ADSI group object

$objGroup = Win32::OLE->GetObject('LDAP://cn=Managers,ou=Sales,dc=mycorp,dc=com');

# **********************************************************************
# Get and write the mail property value, which forces an
# implicit GetInfo call
# **********************************************************************
print $objGroup->Get('mail'), "\n";

# **********************************************************************
# Set the new mail address in the cache
# **********************************************************************
$objGroup->Put('mail', 'new-address@mycorp.com');

# **********************************************************************
# Use an explicit GetInfo call to again retrieve all items into the cache
# **********************************************************************
$objGroup->GetInfo();

print $objGroup->mail, "\n";

This code has been viewed 863 times.

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