Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve Value of MinimumPasswordLength/Max Age

Status
Not open for further replies.

Thinker30

IS-IT--Management
Aug 2, 2002
6
0
0
US
Writting a small security app (VB6) to run against several xp/2k/2k3 machines, currently retrieves patches, users, shares, and specific running apps.

Would like to retrieve and display the MinimumPasswordLength and MaximumPasswordAge.

I can manually get them of course using secpol.msc, but cannot figure quick way to get the local settings and display them in a listview/listbox.

Assistance to atleast send me in the right direction..
 
Figured it out, just in case any one else may need it..

** reference the Active DS Type library...
Code:
Dim owinnt As ActiveDs.IADs
Dim age_max As Long
Dim age_pwd As Long
Dim date_expi As String
Dim MinLength As Long
Dim Compname as String
Dim User as String

Compname = "<Computername>"
User = "<username>"


     On Error Resume Next
    Set owinnt = CreateObject("WinNT://" & Compname & "/" & User)
    
    If Err = 429 Then
        ' login inexistant
        MsgBox "The login " & User & " Does not exist in the Domain: " & strcomputer, vbCritical, "LOGIN INCONNU"
        On Error GoTo 0
    Else
        ' Possible Properties are: LoginHours, Description, LoginScript, FullName, AccountExpirationDate
        ' BadPasswordAttempts, HomeDirDrive, HomeDirectory, LastLogin, LastLogoff, PasswordHistoryLength, LoginWorkstations
        ' MaxLogins, MaxPasswordAge, MaxStorage, MinPasswordAge, MinPasswordLength, PasswordAge, PasswordExpired
        On Error GoTo 0
        
        age_max = CLng(owinnt.Get("MaxPasswordAge")) / 60 / 60 / 24 ' Period of Validity of the password
        MinLength = CLng(owinnt.Get("minPasswordLength"))
        
  MsgBox "Maximum Password Age has been set to: " & age_max
  MsgBox "Mininum Password Length has been set to: " & MinLength
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top