Prevent passwd expiration (Perl)
This code can be found in
Chapter 6 of Active Directory Cookbook, 2nd 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.
# This Perl code sets a users password to never expire
# See Recipe 4.12 for the code for the CalcBit function
# ---------------------------------------------------------------
# Adapted from VBScript code contained in the book:
# "Active Directory Cookbook" by Robbie Allen
# ISBN: 0-596-00466-4
# ---------------------------------------------------------------
# ------ SCRIPT CONFIGURATION ------
my $strUserDN = "<UserDN>"; # e.g. cn=rallen,ou=Sales,dc=rallencorp,dc=com
# ------ END CONFIGURATION ---------
use Win32::OLE;
$Win32::OLE::Warn = 3;
my $intBit = 65536;
my $strAttr = "userAccountControl";
my $objUser = Win32::OLE->GetObject("LDAP://" . $strUserDN);
my $intBitsOrig = $objUser->Get($strAttr);
my $intBitsCalc = CalcBit($intBitsOrig, $intBit, TRUE);
if ($intBitsOrig != $intBitsCalc) {
$objUser->Put($strAttr, $intBitsCalc);
$objUser->SetInfo;
print "Changed $strAttr from $intBitsOrig to $intBitsCalc\n";
}
else {
print "Did not need to change $strAttr ($intBitsOrig)\n";
}
|
This code has been viewed 1344 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|