From: Al L. <al....@fn...> - 2002-02-13 16:12:21
|
Chris Winters wrote: > > On Wed, 2002-02-13 at 10:40, Al Lilianstrom wrote: > > I'm working with Active Directory manipulation from a Unix machine. > > We're going to have a centralized Oracle database feed my code to create > > accounts in AD. One of the items we want to set is the accountExpires > > field - esp for contractors. According to the schema this value is > > stored as a large integer that represents the number of seconds elapsed > > since 00:00:00, January 1, 1970. > > > > It's real easy to get the number of seconds since Jan 1, 1970. But I'm > > unsure what this large integer format is and how to convert to it. > > This is a common unix way to identify time. Jan 1, 1970 is known as the > epoch. Being of a unix heritage, Perl can translate to and from epoch > seconds easily: > > From: > > my $time_sec = get_epoch_seconds(); > my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) > = localtime( $time_sec ); > > To: > > use Time::Local; > my $time_sec = timelocal($sec,$min,$hours,$mday,$mon,$year); > > Note that $mon is a 0 offset value (0..11) in both cases. The $year > value returned from localtime() needs 1900 added to it to be a > human-readable value (e.g., this year localtime returns 102: 102 + 1900 > = 2002). The timelocal() function is a little more flexible and can take > either a 1900-offset value or a four-digit year. > > localtime() is a built-in function (see 'perldoc -f localtime') and > Time::Local is distributed with all modern (5.6+) versions of Perl. > > I recently had to answer this for some of my win32 colleagues, so this > is very much in the front of my mind :-) Chris, Thanks for the snippets - a little simpler than I was using. The problem is that perl will output 1016085600 for the date of march 14th, 2003. The value AD is looking for is 126606456000000000 for that same date. It's this large integer part that had me confused. al -- Al Lilianstrom CD/OSS/CSI Al....@fn... |