Windowsmanager

Many attributes in Active Directory have a syntax called Integer8. These 64-bit numbers (8 bytes) usually represent time in 100-nanosecond intervals. If the Integer8 attribute is a date, the value represents the number of 100-nanosecond intervals since 12:00 AM January 1, 1601.

ADSI automatically employs the IADsLargeInteger interface to deal with these 64-bit numbers. This interface has two property methods, HighPart and LowPart, which break the number up into two 32-bit numbers. The LowPart property method returns values between -2^31 and 2^31 - 1. The standard method of handling these attributes is demonstrated by this VBScript program to retrieve the domain lockoutDuration value in minutes.

Set objDomain = GetObject("LDAP://dc=MyDomain,dc=com")

Set objDuration = objDomain.lockoutDuration

lngDuration = objDuration.HighPart * (2^32) + objDuration.Lowpart

lngDuration = -lngDuration / (60 * 10000000)

Wscript.Echo "Domain policy lockout duration in minutes: " & lngDuration

However, whenever the LowPart method returns a negative value, the calculation above is wrong by 7 minutes, 9.5 seconds. The work-around is to increase the value returned by the HighPart method by one whenever the value returned by the LowPart method is negative. The revised code below gives correct results in all cases.

Set objDomain = GetObject("LDAP://dc=MyDomain,dc=com")

Set objDuration = objDomain.lockoutDuration

lngHigh = objDuration.HighPart

lngLow = objDuration.LowPart

If lngLow < 0 then

  lngHigh = lngHigh + 1

End If

lngDuration = lngHigh * (2^32) + lngLow

lngDuration = -lngDuration / (60 * 10000000)

Wscript.Echo "Domain policy lockout duration in minutes: " & lngDuration

The error introduced if this inaccuracy is not accounted for is not large. The error is always 2^32 100-nanosecond intervals, which is 7 minutes, 9.5 seconds. All the programs on this site that deal with Integer8 attributes have been revised as shown on this page to give accurate results.

The link on the left discusses the details of this problem and unsigned arithmetic. The revised function linked below can be used to convert Integer8 attributes to dates:

 Integer8Date.txt   <<-- Click here to view or download the program

 
Send mail to A Bakker with questions or comments about this web site.
Copyright © 2006 CompanyLongName
Last modified: December 11, 2005