SCM

[#1000565] ActiveDirectory to PgSQL timestamps/intervals conversion ?

View Trackers | Feature Requests | Download .csv | Monitor

Date:
2006-02-23 13:40
Priority:
3
State:
Open
Submitted by:
Nobody
Assigned to:
Nobody (None)
Category:
Interface Improvements (example)
Group:
Summary:
ActiveDirectory to PgSQL timestamps/intervals conversion ?

Detailed description
Several ActiveDirectory user attributes[1] such as accountExpires, badPasswordTime, lastLogoff/lastLogon, pwdLastSet are timestamps defined as:

> This value represents the number of 100 nanosecond intervals
> since January 1, 1601 (UTC).

Other attributes like Max-Pwd-Age[2] are intervals defined as:

> This value is stored as a large integer that represents the number
> of 100 nanosecond intervals from the time the password was set
> before the password expires.

I found some articles, scripts and tools[3] that converts these attributes but, of course, none of them can return a native PostgreSQL timestamp or interval.

I'm not a C guy so I can't write such conversion functions myself... but am I the only one to think it would be a very useful addition to dblink-ldap ? :-)

Regards,

Georges Martin

--
[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/security_properties.asp

[2] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adschema/adschema/a_maxpwdage.asp

[3] http://www.microsoft.com/technet/scriptcenter/topics/win2003/lastlogon.mspx
http://www.rallenhome.com/books/adcookbook/code.html
http://www.joeware.net/win/free/tools/oldcmp.htm

Followup

Message
Date: 2006-10-09 22:11
Sender: Jeff Davis

I browsed the links you sent along.

I assume you receive the data as one big integer represented as a string. Just do a quick function like:

CREATE OR REPLACE FUNCTION ms_time_to_pg_interval(text)
RETURNS INTERVAL AS
$func$
SELECT ((($1::numeric)/('10e6'::numeric))::text
|| ' seconds')::interval;
$func$
LANGUAGE sql;

It's specific enough that I'm not sure it belongs in dblink-ldap. However, I'm not the author so I'll leave it up to him :)

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge