I have been looking in dsquery commands to try to find how to output a list of accounts that are set to never expire but I can't find the correct command. Is this possible with dsquery and if so what is the command?
Here is the code you need to check if a password is set to expire. All you need to do is alter this to loop through each of your users and record the results.
Code:
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set objUser = GetObject("LDAP://CN=myerken,OU=management,DC=fabrikam,DC=com")
intUserAccountControl = objUser.Get("userAccountControl")
If intUserAccountControl And ADS_UF_DONT_EXPIRE_PASSWD Then
WScript.Echo "The password does not expire."
WScript.Quit
Else
WScript.Echo "The password expires."
End If
Thanks for the quick response. Do I just change the LDAP path to reflect my domain and it will go through the users? And do I save it as a vbs script and execute it on the DC? Thanks for the help.
You almost have it. Yes you need to change the LDAP Path, but as you can see from the example it binds to a specific user. So you need to "make this script Enterprise Ready."
I'll be happy to assist you with this effort, however I will first give you a homework assignment and refer you to my FAQ on the subject. faq329-4871 This FAQ should help you understand the kind of changes you will need to make.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.