Link to home
Start Free TrialLog in
Avatar of bugsuperstar37
bugsuperstar37

asked on

Calculate AccountExpires

How do you calculate the Long Integer that is required in Active Directory for the AccountExpires?
Avatar of SysExpert
SysExpert
Flag of Israel image

Good question.

I can give you a method to show you the dates, and you should be able to figure it out from there.

one of the sites below has a utility to print out users and password expiration dates. I'll try to find the exact location..
See


http://www.sysinternals.com/

http://www.sysinternals.com/ntw2k/freeware/ntfsdospro.shtml  NTFS for DOS
http://www.systemtools.com/
http://www.winternals.com
 www.bhs.com
http://www.bhs.com/soft_index.asp

http://www.sunbelt-software.com/search_category.cfm
www.optimumx.com


I hope this helps !

http://www.systemtools.com/free_frame.htm  June 10, 2002 checked for updates.
Yes, these utilities are all FREE !

We have assembled (and in some cases developed) the following free utilities for addressing unique Windows
NT system management problems.  Please direct any questions concerning these utilities to the contact
addresses listed in each application's ReadMe or Help file.

SystemTools TScmd - Developed by SystemTools.  A command-line utility to set terminal server user
settings.  All eighteen (18) terminal server settings can be set.  Includes documentation in readme.txt file.

Password Age - Password Age (formerly "machines"). Displays the age of the password for user and
computer accounts. For computer accounts, this information can be used to determine if the computer is no
longer being used. For users, it can be used to determine which accounts are not being used or have
expired.

----------

I hope this helps !
Avatar of bugsuperstar37
bugsuperstar37

ASKER

Unless you can send me code, these sites are useless. Look, I don't need more tools. Windows provides many. I need to know how to calculate a date as a Long Integer that is acceptable to the Active Directory accountExpires property.
From ADSI SDK:

accountExpires
The accountExpires property specifies when the account will expire. This value is stored as a large integer that represents the number of seconds elapsed since 00:00:00, January 1, 1970. A value of TIMEQ_FOREVER indicates that the account never expires.

Also from ADSI SDK:

Account Expiration

Account Expiration Date can be set using the AccountExpiration method in the IADsUser interface.

Set usr = GetObject("WinNT://ArcadiaBay/JSmith")
usr.AccountExpirationDate = "05/06/1998"
usr.SetInfo
To set the account expiration date to "never", use "January 1, 1970" as the parameter.

You can set the account expiration date by setting the AccountExpirationDate property of the IADsUser interface to a desired date value. To set the account expiration date to "never", set this property to "Janurary 1, 1970".

Example Code [Visual Basic]
Set usr = GetObject("WinNT://ArcadiaBay/JSmith")
usr.AccountExpirationDate = "05/06/1998"
usr.SetInfo
 
// to enable the account forever,
usr.AccountExpirationDate = "01/01/1970"
usr.SetInfo
This is nice, but the truth is I have figured out the 00:00:00, January 1, 1970 portion, the only problem is that I am not working with a Microsoft relater programming language. I am using PHP. But after some serious hit and miss, I have discovered you must add a specific number of zeros to the end and then after calculating leap years and so forth I have found my answer.
---- CLEAN UP ----

bugsuperstar37,
No comment has been added lately (445 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: [ PAQ/Refund ]

Please leave any comments here within the next seven days.

¡PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

------------------------------
Rajiv Makhijani
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Avatar of PashaMod
PashaMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial