ADSI pwdLastSet (to UTC or not to UTC)

Discussion in 'Scripting' started by /\/\o\/\/ [MVP], Jul 17, 2006.

  1. I'm a bit confused about the ADSI pwdLastSet int64 value,
    I was thinking this was an UTC value, but it seems to be in the Local Time:
    Also the PasswordLastChanged method of the ADSI COM object will return a
    local time it seems (I did set this password at 17:07 (UTC + 2 ) ) :

    $user.pwdLastSet = -1

    $ds = New-Object directoryservices.directorysearcher($user)

    MowPS>[datetime]::fromfiletime(($ds.findone().properties.pwdlastset)[0])

    Monday, July 17, 2006 5:07:05 PM


    MowPS>$user.InvokeGet('PasswordLastChanged')

    Monday, July 17, 2006 5:07:05 PM


    MowPS>[datetime]::fromfiletimeutc(($ds.findone().properties.pwdlastset)[0])

    Monday, July 17, 2006 3:07:05 PM

    I think this is very strange as I did think all the ADSI Uint64 dates where
    in UTC time also most examples calculate the Bias, also this way you do not
    know the timezone it was set so its not possible to calculate the precice
    time.

    any ideas ?

    Greetings /\/\o\/\/
     
    /\/\o\/\/ [MVP], Jul 17, 2006
    #1
    1. Advertisements

  2. Hi,

    The pwdLastSet attribute stores the date value in UTC. However, the
    PasswordLastChanged property method converts to local time. When I compare
    the value returned by PasswordLastChanged to the value I get when I convert
    pwdLastSet to a date (corrected for the local time zone), the values agree
    within a second.

    --
    Richard
    Microsoft MVP Scripting and ADSI
    Hilltop Lab - http://www.rlmueller.net

     
    Richard Mueller, Jul 17, 2006
    #2
    1. Advertisements

  3. Thanks seems I did misunderstand the fromfiletimeUtc function
    that will Give it as UTC the other will convert it allready.
    so I do need the "normal" fromFileTime


    PoSH>[datetime]::fromfileTime([datetime]::now.ToFileTime())

    Monday, July 17, 2006 7:23:58 PM


    PoSH>[datetime]::fromfileTime([datetime]::now.ToFileTimeutc())

    Monday, July 17, 2006 7:24:00 PM


    PoSH>[datetime]::fromfileTimeUtc([datetime]::now.ToFileTimeutc())

    Monday, July 17, 2006 5:24:25 PM

    PoSH>[datetime]::fromfileTimeUtc([datetime]::now.ToFileTime())

    Monday, July 17, 2006 5:25:27 PM
     
    /\\/\\o\\/\\/, Jul 17, 2006
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.