Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem setting Account Expiry Date in AD

Status
Not open for further replies.

BillDoor

IS-IT--Management
Jun 28, 2004
112
GB
Hi I am trying to set the Expiry Date of a user in active directory, with a VBScript. I have found the following example and I am trying to test it:

Code:
Set objUser = GetObject("LDAP://cn=Username,ou=Users,dc=XXXXXXXX,dc=XXX")

objUser.AccountExpirationDate = CDate("21/02/2007")
objUser.SetInfo

The script seems to run OK, I don't get any errors, but when I look at the user account in users & computers, the expiry date is 19 February 2007 two days earlier then I specified.

If I query the value with a script then I get the date I entered ("21/02/2006").

Am I doing something wrong, or is this a bug. I have looked but I haven't found any mention of a bug.

btw I have just recently upgraded from WinXP SP1 to WinXP SP2.
 
If you have more than 1 Domain Controller then you may have to wait for the servers to syncronize. When you are in "User and Computers", right click over the domain and select "Connect to Domain Controller". Select a different DC from the list and see if that server reports something different.
 
You're right we have 6 DCs. I tried again, this time setting the exiry date to 05/08/2007 (5th August 2007) just before I went home for the night. I have checked the account on all 6 DCs this morning and they all say 04/08/2007.

The script I am trying to write is to create temporary user accounts for visitors/contactors and I need them to expire after seven days. Is there another way to set this value that is more accurate?
 
Are your PC and server running different daylight savings configurations? If that is the case, it could explain why one day is missing as when you run the script, it could be loosing an hour which could explain a day difference (not too sure why two days though...).

The TID below refers to Windows XP, but I would have thought the same principle applies for AD too:


--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top