Skip to main content
Participant
September 22, 2010
Question

has anyone created MS filetime converter for CF?

  • September 22, 2010
  • 3 replies
  • 815 views

I'm trying to authorize user via ldap to see if they are currently 'logged in'.

normal method would be compare login time against current time and require a new login every 4 hours.

my problem is that LDAP time string is huge (ex: 129296092840348948) .. lots of googling leads me to believe this is MS filetime data type (a composite of two 32-bit numbers).

problem is converting it into something usable.. everything I find about converting refers to a MS system call named FileTimeToSystemTime()

has anyone done this in CF?

This topic has been closed for replies.

3 replies

Participant
September 22, 2010

cfsearching... ya.. I could just do an exec vb script inside the cf code.. yeah.. uh..    ... actually , that was what I found when I was out looking around.. MS has built in functions for doing the conversion.. but its not a CF solution.

PaulH - you've got a lot of good stuff there

I eventually found my answer on a unix forum (after 4 hours of searching and digging thru all the crap) .. and here is the CF solution:

<cffunction name="fileTimeConvert" access="public" output="false">

<cfargument name="timeString" required="true" type="Numeric">

     <cfset var result = ''>

      <!--- remove last 7 digits: --->

     <cfset var myTempTime = Left(arguments.timeString,11)>

     <!--- subtract 11644473600, which is seconds from 1601 to 1970 I think --->

     <cfset myTempTime = myTempTime -11644473600 >           

     <!--- myTempTime is now UNIX epoch time, and do dateAdd: --->

     <cfset result = DateAdd("s", myTempTime, "January 1 1970 00:00:00")>

     <cfreturn result>
</cffunction>
Inspiring
September 22, 2010

I was thinking if it was some weird MS specific time, and all else failed, you could always call a .net library from CF. But obviously I did not look into it that deeply Glad you found a simpler solution.

-Leigh

Participant
September 22, 2010

actually, I think it is a weird ms-specific thing ... they have a built-in function in VB and C/+ to do the conversions, and I had to dig a long time to figure out what it was. CF was blowing up because it couldn't handle 64-bit integers when I was just trying to do simple math on the values.

Inspiring
September 22, 2010

http://bit.ly/bdC4KT

Inspiring
September 22, 2010

Haha. I should have known the time master would have something in his arsenal

Inspiring
September 22, 2010

I cannot say I know anything about it. But a quick google suggests there there is a .net function that might be of use: DateTime.FromFileTime

http://bytes.com/topic/net/answers/123957-filetimetosystemtime-dotnet

http://msdn.microsoft.com/en-us/library/system.datetime.fromfiletime.aspx

-Leigh