Coder Social home page Coder Social logo

Comments (7)

w-p avatar w-p commented on August 28, 2024 1

The accountExpires attribute is an AD timestamp like lastLogon and badPasswordTime.

accountExpires
attribute: https://msdn.microsoft.com/en-us/library/ms675098(v=vs.85).aspx
schema: https://msdn.microsoft.com/en-us/library/Cc221084.aspx

badPasswordTime
attribute: https://msdn.microsoft.com/en-us/library/ms675243(v=vs.85).aspx
schema: https://msdn.microsoft.com/en-us/library/Cc221229.aspx

Both of these attributes have the same attributeSyntax and omSyntax values however, while badPasswordTime is sent through the formatter, accountExpires is not.

from ldap3.

cannatag avatar cannatag commented on August 28, 2024

Hi Will, what is the syntax of this attribute in the schema? Are you using the get_info=SCHEMA parameter in the server object? If the accountExpires has a custom format it can be added to the standard formatter of ldap3.

from ldap3.

w-p avatar w-p commented on August 28, 2024

Apologies, the issue is apparently not that the attribute itself is not being formatted but rather that the value presented by AD is not being accounted for. In the case of accountExpires the AD timestamp uses the value 9223372036854775807 to indicate that the account will never expire.

I don't think there is an infinity representation of a datetime object in Python so perhaps returning float('inf') in this particular case would make sense? This works nicely for JSON representation.

So, in format_ad_timestamp() there could be something like:

if raw_value == b'9223372036854775807':
    return float('inf')

I'm not sure of the performance implications though.

from ldap3.

cannatag avatar cannatag commented on August 28, 2024

HI Will, that value is used to represent the highest value that can be stored in a 64 bit signed integer ( 2^63 − 1 or 7FFF FFFF FFFF FFFF in hex) and in this case should mean the highest date that can be stored in the accountExpires attribute.

To be consistent with the value returned by format_ad_timestamp() I prefer:

if raw_value == b'9223372036854775807':  # max value to be stored in a 64 bit signed int
    return datetime.max  # returns datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)

This return the highest date managed by the python datetime module and should not break existing code.

from ldap3.

w-p avatar w-p commented on August 28, 2024

I was just about to revise my previous assertion. You are correct. Staying standard is the right way to go. Thanks.

from ldap3.

cannatag avatar cannatag commented on August 28, 2024

Will release it in the next release.

bye,
Giovanni

from ldap3.

cannatag avatar cannatag commented on August 28, 2024

Fixed in 0.9.9

from ldap3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.