2

I'm trying to get all the accounts that have EXPIRED using accountExpires attribute in Active Directory.

As the attribute type is Int8 (64-bit integer) and coldfusion does not support such long integer, I am having a hard time getting this to work.

Is there a function or some sort that I can use to acheive the above?

Thanks!

James
  • 579
  • 10
  • 26

1 Answers1

3

A 64 bit integer in Java is a java.lang.Long. Longs are implicitly converted to Integers in ColdFusion.

accountExpires is a windows file time structure representing the number of 100-nanosecond intervals since January 1, 1601. This thread shows how we can get a windows file time to date:

long diff1601to1970 = 315532800 * 1000000000; // <-- diff in nanoseconds(1/1/1601 to 1/1/1970)
long currentFrom1970 =  System.currentTimeMillis() * 1000000;
long currentFrom1601 = diff1601to1970 + currentFrom1970;

Which allows us to do the following in ColdFusion:

accountExpiresFileTime = 129407978957060010;
date = createObject("java", "java.util.Date").init(
    (accountExpiresFileTime-116444736000000000)/10000
);

Hopefully that helps.

Community
  • 1
  • 1
James Hull
  • 3,669
  • 2
  • 27
  • 36
  • Hello, Thanks for the reply. I've tried `` `` I get the error : INIT Can not find the appropiate constructor to call, Please use javacast to specify parameter type. but when I try: `` it is OK. Any idea? :( – James Dec 16 '11 at 05:18
  • Works for me. CF 9,0,1,274733. Sometimes coldfusion can get confused with overloaded java methods. So try wrapping your argument in a java cast `` – James Hull Dec 16 '11 at 10:06
  • I'm running CF5 at the moment. I'm pretty sure I've tried javacast before but I'll double check on Monday – James Dec 18 '11 at 00:59
  • Ok,for some reason, the CFLDAP is failing to retrieve accountExpires attribute. Same for all other Int8 attributes. Any idea how to get this to work? :( – James Dec 19 '11 at 03:57
  • I don't I am afraid - however that is a different question so I suggest you post it as a separate question. But once you have found out why cfldap isn't working - at least you now know how to use the windows file time in CF! – James Hull Dec 23 '11 at 22:45