Forum Search:
Forum.Brain-Cluster.com: Brain Cluster Technical Forum
Ultimate forum for Technical Discussions

Home » Microsoft » Windows Server » Windows Server General Help » How to get Windows 'Password Age' using API?
How to get Windows 'Password Age' using API? [message #163521] Wed, 03 June 2009 03:31 Go to next message
liyong  is currently offline liyong  China
Messages: 23
Registered: July 2009
Junior Member
hello,
How to get local 'Max Password Age' using API? I means Computer 's
password Age, not the 'max password age' of 'Domain user'
it should can work in XP and Windows 2003.

you can using the following steps see it:
Start Menu->Control Panel->Administrative Tools->Local Security
Settings->Account Policies->Password Policy-> Maxmium Password Age, default
value is 42 days.


thanks a lot.
Re: How to get Windows 'Password Age' using API? [message #163560 is a reply to message #163521] Wed, 03 June 2009 10:11 Go to previous messageGo to next message
rlmueller-nospam  is currently offline rlmueller-nospam  United States
Messages: 292
Registered: July 2009
Senior Member
"liyong" <liyong@cyberresource.com.cn> wrote in message
news:ulkoQ1B5JHA.1416@TK2MSFTNGP04.phx.gbl...
> hello,
> How to get local 'Max Password Age' using API? I means Computer 's
> password Age, not the 'max password age' of 'Domain user'
> it should can work in XP and Windows 2003.
>
> you can using the following steps see it:
> Start Menu->Control Panel->Administrative Tools->Local Security
> Settings->Account Policies->Password Policy-> Maxmium Password Age,
> default value is 42 days.
>
>
> thanks a lot.

I've never seen an API, but you can use the WinNT provider. The
maxPasswordAge attribute (in seconds) is a property of local user objects,
not the computer object, so you must bind to a user. For example, in VB or
VBScript:
========
Option Explicit
Dim objComputer, strComputer, strUser, lngMaxAge

strComputer = "MyComputer"
strUser = "Administrator"
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser & ",user")
lngMaxAge = objUser.maxPasswordAge
Wscript.Echo "Max Password Age in Seconds: " & CStr(lngMaxAge)
Wscript.Echo "Max Password Age in Days: " & CStr(lngMaxAge / (60 * 60 * 24))

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Re: How to get Windows 'Password Age' using API? [message #164172 is a reply to message #163560] Wed, 17 June 2009 03:18 Go to previous message
liyong  is currently offline liyong  China
Messages: 23
Registered: July 2009
Junior Member
hello, Richard:

I used the methods you provided to test the result, it works well on my
desk top(Windows XP),but it seems it can not work on server 2003,
I got the following data on Server2003: 3710851 seconds, it not 42 days.

3710851/86400=>42.94966435185185

could you give more info about how to use WINNT provider?

"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> 写入消息新闻:e8Nm7UF5JHA.5048@TK2MSFTNGP03.phx.gbl...
>
> "liyong" <liyong@cyberresource.com.cn> wrote in message
> news:ulkoQ1B5JHA.1416@TK2MSFTNGP04.phx.gbl...
>> hello,
>> How to get local 'Max Password Age' using API? I means Computer 's
>> password Age, not the 'max password age' of 'Domain user'
>> it should can work in XP and Windows 2003.
>>
>> you can using the following steps see it:
>> Start Menu->Control Panel->Administrative Tools->Local Security
>> Settings->Account Policies->Password Policy-> Maxmium Password Age,
>> default value is 42 days.
>>
>>
>> thanks a lot.
>
> I've never seen an API, but you can use the WinNT provider. The
> maxPasswordAge attribute (in seconds) is a property of local user objects,
> not the computer object, so you must bind to a user. For example, in VB or
> VBScript:
> ========
> Option Explicit
> Dim objComputer, strComputer, strUser, lngMaxAge
>
> strComputer = "MyComputer"
> strUser = "Administrator"
> Set objUser = GetObject("WinNT://" & strComputer & "/" & strUser &
> ",user")
> lngMaxAge = objUser.maxPasswordAge
> Wscript.Echo "Max Password Age in Seconds: " & CStr(lngMaxAge)
> Wscript.Echo "Max Password Age in Days: " & CStr(lngMaxAge / (60 * 60 *
> 24))
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
Previous Topic:WDS image without sysprep
Next Topic:Server Backup-Image (full, inc, encrypted)
Goto Forum:
  


Current Time: Wed Aug 23 07:51:34 EDT 2017

Total time taken to generate the page: 0.05456 seconds
.:: Contact :: Home ::Sitemap::.

Powered by: FUDforum 3.0.0RC2.
Copyright ©2001-2009 FUDforum Bulletin Board Software