Blog Stats
  • Posts - 45
  • Articles - 0
  • Comments - 16
  • Trackbacks - 20

 

Monday, November 14, 2005

more Active Directory funkiness

We had a bug that got reported on November 1 this year. Nobody could figure out the reason for the bug except that the possible module for the bug had to be a module that I wrote. The bug was reported across all the clients. The condition had not occured before even during extensive testing.
I could not reproduce the bug on my machine nor could the testing team. We were quite confounded by the bug till someone pointed out that Nov 1 was right after we moved to daylight savings time. This gave me a funny feeling because my module did query the domain for time. After some checks, it turns out that the ADSI returns different times before and after daylight savings time kicks in. So if you were to query any time based parameters from the AD (such as time password changed) it will return a different value before and after the time change. This is because all time based parameters are returned as long values representing the difference between the current system time and a fixed date (Jan 1, 1969 or some variation thereof). This difference changes when daylight savings time kicks in.
Has anybody dealt with this issue before? I cannot figure out a way in which I can query the AD for UTC time instead of system time.
I have an ugly hack in mind as the solution: change the time I store when the system time changes, but I am afraid I am going to introduce more bugs than necessary - what with the change in daylight savings time in 2007.

UPDATE:
After sitting on this problem for the week I found the source fo the error. We were using a wrapper function around AD provided by Microsoft which gave the time as a double value so that it can be accurately displayed as a date. Instead we now fetch the property from the IADSUser object. During the return, it turns out that AD makes a reverse query to the computer making the request and fetches the system time. The reply depends on the system time. If you are storing any property, you have to be very careful - and hopfully not spend a week on the problem. Kudos to my co-workers who helped me solve this issue :p
 

 

Copyright © Rishi Pande