[New-bugs-announce] [issue13825] Datetime failing while reading active directory time attribute

Chris Gill report at bugs.python.org
Thu Jan 19 15:14:17 CET 2012

New submission from Chris Gill <chrisfgill at gmail.com>:

I believe I am having a similar issue to this: http://bugs.python.org/issue7150

I am in the middle of programming a quick script and now I cannot seem to get beyond this issue; as it is printing up the expiration times from the AD user listings (many of which print 1601 year) it finally fails after the same user account, I have compared accounts and the expiration is the same as other accounts in AD: which is set to (never)

any ideas of what's going on here and how I can bypass this error?

error report: 

Traceback (most recent call last):
... line 14, in <module>
    print user.name + ": " + str(user.accountExpires)
  File "C:\Python27\lib\site-packages\active_directory.py", line 425, in __getattr__
    self._delegate_map[name] = converter (attr)
  File "C:\Python27\lib\site-packages\active_directory.py", line 335, in convert_to_datetime
    return ad_time_to_datetime (item)
  File "C:\Python27\lib\site-packages\active_directory.py", line 319, in ad_time_to_datetime
    return BASE_TIME + delta
OverflowError: date value out of range


import active_directory
from datetime import datetime,timedelta

##check AD for account expirations
users = active_directory.AD_object ("LDAP://ou=administration,dc=domain,dc=com")
for user in users.search (objectCategory='Person'):

    dn = user.distinguishedName
    dn = dn.encode("utf-8") #for the occasional apostrophe

    if "Adjuncts" in str(dn):
        print user.name + ": " + str(user.accountExpires)

print "done"

example output:

CN=John Hancock: 1601-01-01 00:00:00
CN=Jane Smith: 1601-01-01 00:00:00

components: IDLE, Windows
messages: 151622
nosy: Chris.Gill
priority: normal
severity: normal
status: open
title: Datetime failing while reading active directory time attribute
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list