?
Solved

How to I identify "User must change password at next logon" attribute in Active Directory

Posted on 2009-06-29
2
Medium Priority
?
901 Views
Last Modified: 2012-08-13
I simply want to enumerate the accounts in active directory that have the "User must change password at next logon" box checked. I have attached a bitmap to show you what I am refering to and the code for enumeration is included. Prefereably the solution should be in vbscript or vb.
SelectValue = "REGIS T. HYDE"
SetLdapRecordSource CnUserRs, CnUserCn, SelectValue, 1 
 
Do While Not CnUserRs.EOF 
 
WScript.Echo CnUserRs.Fields("pwdLastSet").value
 
CnUserRs.Movenext
Loop
CloseTables CnUserRs,CnUserCn
 
 
 
 
 
Sub Get_Record_Set(ByRef RsVal)
 
'***********************'
'*       Summary       *'
'***********************'
'****************************************************************************'
'*    This module will create an ado recordset object. It basically sets    *'
'*    aside memory allocation for the source that will be used for data     *'
'*    manipulation.                                                         *'
'****************************************************************************'
   
    Set RsVal = CreateObject("ADODB.Recordset")
        
End Sub
 
 
 
Sub SetLdapRecordSource(ByRef RsTemp, ByRef cnTemp,ByRef SelectValue, ByRef CaseTemp)
    
    Get_Record_Set RsTemp
    Open_LdapConnection RsTemp, cnTemp
    Select_Source RsTemp, SelectValue, CaseTemp
   
End Sub
 
 
 
Sub Open_LdapConnection(ByRef RsVal1, ByRef cnTemp)
 
'***********************'
'*       Summary       *'
'***********************'
'****************************************************************************'
'*    This module will create an ado connection object. It basically allows *'
'*    the recordset to attach to the appropriate ldap data source.          *'
'****************************************************************************'
   
    Const ADS_SCOPE_SUBTREE = 2
    
    Set cnTemp = CreateObject("ADODB.Connection")
    cnTemp.ConnectionString = "Provider=ADsDSOObject"
    cnTemp.Open
   
    RsVal1.ActiveConnection = cnTemp
    'RsVal1.Properties("searchscope") = ADS_SCOPE_SUBTREE
    
    RsVal1.Properties("Page Size") = 1000
    RsVal1.Properties("Timeout") = 30  
    RsVal1.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
    RsVal1.Properties("Cache Results") = False 
    
    
    
    
    RsVal1.CursorLocation = 3
    RsVal1.LockType = 3
   
    
End Sub
 
 
 
Sub Select_Source(ByRef RsVal, Byref SelectValue ,ByVal SourceNum)
 
 
 
Select Case SourceNum
 
 
 
Case 1
         
          RsVal.Source ="<LDAP://DC=winroot,DC=svmh,DC=com>;" & _   
          "(&(objectCategory=person)(objectClass=user)(cn=" & SELECTVALUE & "));" & _ 
          "cn,pwdLastSet,distinguishedName,SamaccountName,extensionAttribute1,msExchHomeServerName,mail;subtree" 
          RsVal.Sort = "cn ASC" 
          
 
            
        End Select
    
  
  
  RsVal.Open
  If RsVal.EOF Then
    Exit Sub
  End If
  RsVal.MoveFirst
  
 
            
    
End Sub
 
 
 
 
 
Sub CloseTables(ByRef RsVal1, ByRef cnTemp)
    RsVal1.Close
    cnTemp.Close
    Set RsVal1 = Nothing
    Set cnTemp = Nothing
End Sub

Open in new window

AD-USER.bmp
0
Comment
Question by:BLACK THANOS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 47

Expert Comment

by:Donald Stewart
ID: 24740562
0
 

Accepted Solution

by:
BLACK THANOS earned 0 total points
ID: 24761065
i figured it out. I will post the code tomorrow. It CAN BE DONE.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

770 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