I could be wrong, but you're likely looking for this:
 
 
Al


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Creamer, Mark
Sent: Tuesday, July 20, 2004 4:00 PM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] useraccountflag

Robbie's cookbook contains code on setting a password to never expire, but what if I want to set those that are set to never expire to start expiring? How would I alter the code? I tried setting to 512 (normal account), but it returns:

"Did not need to change userAccountControl (66048)"

 

Here's the code as altered by me to change the flag back to a normal account whose password does expire:

 

*********************************************

strUserDN = "CN=O'Tester\, GP,OU=TestOU,DC=na,DC=cintas,DC=com"

intBit = 512

strAttr = "userAccountControl"

Set objUser = GetObject("LDAP://" & strUserDN)

intBitsOrig = objUser.Get(strAttr)

intBitsCalc = CalcBit(intBitsOrig, intBit, True)

If intBitsOrig <> intBitsCalc Then

      objUser.Put strAttr, intBitsCalc

      objUser.SetInfo

      WScript.Echo "Changed " & strAttr & " from " & intBitsOrig & " to " & intBitsCalc

Else

      WScript.Echo "Did not need to change " & strAttr & " (" & intBitsOrig & ")"

End If

 

 

Function CalcBit(intValue, intBit, boolEnable)

CalcBit = intValue

 

If boolEnable = True Then

      CalcBit = intValue Or intBit

Else

      If intValue And intBit Then

            CalcBit = intValue Xor intBit

      End If

End If

 

Thanks for any help!

Mark Creamer

 

Reply via email to