Login | |
|
 |
Re: Reset Network Password - 5/27/2005 1:16:31 AM
|
|
 |
|
| |
tnoonan
Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
|
'On Error Resume Next Dim objRootDSE, strDNSDomain, objCommand, objConnection Dim strBase, strFilter, strAttributes, strQuery, objRecordSet Dim strGN, strDisplay, strLast, strLN, strDN Dim MyArr ' Determine DNS domain name. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") ' Use ADO to search Active Directory. Set objCommand = CreateObject("ADODB.Command") Set objConnection = CreateObject("ADODB.Connection") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" objCommand.ActiveConnection = objConnection strBase = "<LDAP://" & strDNSDomain & ">" 'Change this to the Netbios Domain Name strNetBiOSDomain = "Curriculum" Const ADS_NAME_TYPE_NT4 = 3 Const ADS_NAME_TYPE_1779 = 1 Do while strlast <> "quit" Choice = inputbox("1. Login Name or " & vbcrLF & "2. Search by Last Name" & vbcrLF & " Type quit to exit","Password Reset Script","1") If Choice = "quit" Then Wscript.Quit Else If Choice = 1 Then strUser = inputbox("Enter Login Name","Login Name","") ChangePassword(strUser) Else strLast = inputbox("Enter Last Name","Last Name","") strFilter = "(&(objectCategory=person)(objectClass=user)(sn=" & strLast & "))" strAttributes = "givenName,sn,sAMAccountName,physicalDeliveryOfficeName" strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree" objCommand.CommandText = strQuery objCommand.Properties("Page Size") = 20 objCommand.Properties("Timeout") = 30 objCommand.Properties("Cache Results") = False objCommand.Properties("Sort On") = "givenName" Set objRecordSet = objCommand.Execute Set objRecordSetArr = objCommand.Execute If objRecordSet.EOF Then Wscript.Echo "No user found with last name: " & strLast End If DisplayName End If End If Loop '----- Load up Recordset into Array Function DisplayName MyArr = objRecordsetArr.GetRows() '- Add 1 to end of array to get all of the rows Upper = Ubound(myarr,2)+1 x=0 y=0 a=y+1 'Load up arrays with up to 100 usernames found. Can only display 25 usernames at a time due to InputBox limitations b=25 Do Until y=b or y=Upper Display = Display & vbCrLf & a & ". " & myarr(x,y) & " " & myarr(x+1,y) & " " & myarr(x+2,y) & " " & myarr(x+3,y) a=a+1 y=y+1 Loop b=50 Do Until y=b or y=Upper Display1 = Display1 & vbCrLf & a & ". " & myarr(x,y) & " " & myarr(x+1,y) & " " & myarr(x+2,y) & " " & myarr(x+3,y) a=a+1 y=y+1 Loop b=75 Do Until y=b or y=Upper Display2 = Display2 & vbCrLf & a & ". " & myarr(x,y) & " " & myarr(x+1,y) & " " & myarr(x+2,y) & " " & myarr(x+3,y) a=a+1 y=y+1 Loop b=100 Do Until y=b or y=Upper Display3 = Display3 & vbCrLf & a & ". " & myarr(x,y) & " " & myarr(x+1,y) & " " & myarr(x+2,y) & " " & myarr(x+3,y) a=a+1 y=y+1 Loop 'Display arrays can add more arrays to display more than 100 results. If Upper > 25 Then Display = Display & vbcrLf & "Enter '999' for more results" Choice1 = inputbox("User(s) found: Choose which one to reset password to default" & Display, "Last Name Search","0")' Else Choice1 = inputbox("User(s) found: Choose which one to reset password to default" & Display, "Last Name Search","0")' End If If Choice1 <= 25 Then PassChanged = ChangePass(choice1) Exit Function End If If Upper > 50 Then Display1 = Display1 & vbcrLf & "Enter '999' for more results" Choice1 = inputbox("User(s) found: Choose which one to reset password to default" & Display1, "Last Name Search","0")' Else Choice1 = inputbox("User(s) found: Choose which one to reset password to default" & Display1, "Last Name Search","0")' End If If Choice1 <= 50 Then PassChanged = ChangePass(choice1) Exit Function End If If Upper > 75 Then Display2 = Display2 & vbcrLf & "Enter '999' for more results" Choice1 = inputbox("User(s) found: Choose which one to reset password to default" & Display2, "Last Name Search","0")' Else Choice1 = inputbox("User(s) found: Choose which one to reset password to default" & Display2, "Last Name Search","0")' End If If Choice1 <= 75 Then PassChanged = ChangePass(choice1) Exit Function End If If Upper > 100 Then Display3 = Display3 & vbcrLf & "Enter '999' for more results"
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|