VMware Cloud Community
jonathanvh
Enthusiast
Enthusiast
Jump to solution

Check when the password will expire for an AD User

I need some help for checking when the password will expire for an AD user via Orchestrator.

The passwords expire every 90 days.

I found code to show me when the password was last set but it is not readable.

pwdLastSet = user.getAttribute("pwdLastSet");

System.log("Password last set: " + pwdLastSet);

Output:

[2015-01-15 10:23:46.208] [I] Password last set: 130657846662968750

I found this about this pwdLastSet value: the value is stored as a large integer that represents the number of 100 nanosecond intervals since January 1, 1601 (UTC)

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
rszymczak
Hot Shot
Hot Shot
Jump to solution

@andrewsardinha

No such thing as native .Net or PowerShell integration in workflows, you'd have to run it on a remote PS host which wouldn't be elegant.

But you're right about the windows-epoch (I was not aware MS also had a custom epoch time). Details can be found here where it also sais that pwdLastSet is one of the fields used with windows-epoch.

@jonathanvh

Seems like you have to do the conversion yourself then. No build in function in basic JS that I would know for windows-epoch. Without looking into it in detail, it seems to be quite easy looking at this example in C.

Basicly all you need to do to convert from UNIX-time to WINDOWS-Time is this:

unixtime = (wintime - 116444736000000000) / 100000

Then just use something like this to get your date object in javascript:

var pwdate = new Date(Math.round(unixtime))

View solution in original post

0 Kudos
4 Replies
rszymczak
Hot Shot
Hot Shot
Jump to solution

Yes, that's a standard way for saveing date information called UNIX-Time. Everything you want to know about it can be found here: Epoch Converter - Unix Timestamp Converter

In fact that's also how AD stores the date as LDAP attribute. You need to convert it to whatever you want. Ideally you want to convert it into a Date object so you can later on get any value you need from the Date object (day, month, year, whatever)

Got not vCO here to verify but something along the lines like this should work:

var pwdate = new Date(milliseconds) //note that the input time here is in milliseconds, if your value in in nanoseconds (I doubt it is since afaik Apple is the only company to do such strange things) than you have to divide your value by 1000 to make it into milliseconds

you can then use the methods available on the Date object to get whatever you need, see http://www.w3schools.com/jsref/jsref_obj_date.asp



0 Kudos
andrewsardinha
Enthusiast
Enthusiast
Jump to solution

I'll admit that I don't know the first thing about vCO. Can you use any dotnet or powershell in your workflow? If you can you can try the command below. Windows Epoch time starts at 1601 like you said and the value is measured in ticks. I believe UNIX Epoch time start in 1970 which is why the UNIX values are much smaller.

I use the command below in a PowerShell function to easily convert the value to a human readable format without needing to use a link like the previous user posted. At least this way I can feed the Epoch value through the pipeline to my function and get something useful to use pretty quickly.

If PowerShell / dotnet aren't an option to use in vCO then I'm afraid I won't be much help.

Good luck

([datetime]"1/1/1601").AddTicks(pwdlastset).ToLocalTime()

0 Kudos
rszymczak
Hot Shot
Hot Shot
Jump to solution

@andrewsardinha

No such thing as native .Net or PowerShell integration in workflows, you'd have to run it on a remote PS host which wouldn't be elegant.

But you're right about the windows-epoch (I was not aware MS also had a custom epoch time). Details can be found here where it also sais that pwdLastSet is one of the fields used with windows-epoch.

@jonathanvh

Seems like you have to do the conversion yourself then. No build in function in basic JS that I would know for windows-epoch. Without looking into it in detail, it seems to be quite easy looking at this example in C.

Basicly all you need to do to convert from UNIX-time to WINDOWS-Time is this:

unixtime = (wintime - 116444736000000000) / 100000

Then just use something like this to get your date object in javascript:

var pwdate = new Date(Math.round(unixtime))

0 Kudos
jonathanvh
Enthusiast
Enthusiast
Jump to solution

Thanks!

This is working.

0 Kudos