?
Solved

How can i find just users who dont have the Password never expires checked in just one OU. ADS

Posted on 2008-11-17
10
Medium Priority
?
443 Views
Last Modified: 2012-05-05
Hi,

How can i find just users who dont have the Password never expires checked in just one OU.
Scan all users in an OU and find just users who dont have this option checked.

Regards
Sharath
0
Comment
Question by:bsharath
10 Comments
 
LVL 20

Expert Comment

by:wolfcamel
ID: 22975991
you can select all the users and then check this option and it will apply it to all the users (and not upset any other settings.
0
 
LVL 11

Author Comment

by:bsharath
ID: 22976031
But i just want to find who does not have it.

Any i need to leave is setting untoched for some and change for some...
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22976143
You can try this - changing the path to your OU..
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
 
strADSPath = "LDAP://OU=YourOU,DC=Domain,DC=com"
Set colUsers = GetObject(strADSPath)
colUsers.Filter = Array("User")
 
For Each objUser in colUsers
   If objUser.UserFlags And ADS_UF_DONT_EXPIRE_PASSWD Then
        Wscript.Echo objUser.Name & ": Password not required."
    Else
        Wscript.Echo objUser.Name & ": Password required."
    End If
Next

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Expert Comment

by:Briguy_572
ID: 22976364
rename this file to .vbs
change line 23 to use the path to the OU you want to use.
run the file from the command line with starting with cscript.exe filename.
You can get the OU's distinguishedName from ADSI edit among other tools.
users-OU-Account-not-Expire.txt
0
 
LVL 11

Author Comment

by:bsharath
ID: 22983668
Sirbounty i get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Get Pass.vbs
Line:      8
Char:      4
Error:      Object doesn't support this property or method: 'objUser.UserFlags'
Code:      800A01B6
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------
0
 
LVL 11

Author Comment

by:bsharath
ID: 22983676
Briguy_572

this seems to work but needresults to a file
And just users who have the password never expires box checked.
In times to change it to even query for unchecked
0
 
LVL 11

Author Comment

by:bsharath
ID: 22983677
Briguy_572

this seems to work but needresults to a file
And just users who have the password never expires box checked.
In times to change it to even query for unchecked
0
 
LVL 2

Expert Comment

by:Briguy_572
ID: 22985016
this one outputs creates a log file that has the names of the accounts that do have the "password does not expire" check mark checked.
it currently is creating the file at the root of the c:\ --> you can change the path on line 10 (just make sure the path exists).  Dont forget to change line 26 to use your OU.

OU-Account-not-Expire-2.txt
0
 
LVL 2

Expert Comment

by:Briguy_572
ID: 22985123
this one creates separate files for users that expire and users that dont expire - and puts a date and time stamp in the log file's name - this way you can have some sort of historical record (on this day, these accounts had it set to expire, today, these accounts, etc).  
I think the two log files is what you meant by "In times to change it to even query for unchecked".  Use the file you like.
dont forget ot change line 37 to use your domain.
0
 
LVL 2

Accepted Solution

by:
Briguy_572 earned 2000 total points
ID: 22985132
sorry- i keep hitting the "submit" button when i mean to hit "attach file".

OU-Account-not-Expire-4.txt
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question