Search code examples
python-3.xldap3

how to modify a generalized time attribute with ldap3


how can I modify a generalized time attribute via modify_replace with ldap3?

if I try:

reset_time = datetime.datetime(1970,1,1, tzinfo=datetime.timezone.utc)
c.modify(dn, {'myGeneralizedTimeAttribute': [(MODIFY_REPLACE, [reset_time])]})

I get the following python error: TypeError: 'datetime.datetime' object is not iterable

then I try: c.modify(dn, {'myGeneralizedTimeAttribute': [(MODIFY_REPLACE, [(reset_time,)])]}) and get TypeError: 'datetime.datetime' object cannot be interpreted as an integer

after that I convert datetime to timestamp and get ldap error:

{'result': 19, 'dn': '', 'type': 'modifyResponse', 'message': 'NDS error: syntax violation (-613)', 'description': 'constraintViolation', 'referrals': None}

I think the solution is very simple, but I don't see it...


Solution

  • solved the problem by replacing reset_time with a string:

    reset_time = '19700101010000Z'