Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Reset Network Password

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3138
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Reset Network Password
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Reset Network Password - 5/27/2005 12:16:57 AM   
  dave.steadman

 

Posts: 1
Score: 0
Joined: 5/27/2005
From:
Status: offline
I am looking for a little script to enable me to change the passwords of network users on a workstation. I am fed up with walking to and from the server room to change passwords ;>)


strUser = InputBox("Enter Log On name of user")

Set objUser = GetObject _
("LDAP://cn=" & strUser & ",ou=Curriculum Users,dc=Curriculum,dc=Com")

objUser.SetPassword "password"

I picked this code up from the internet and it seems to have some of what I need - except for the fact I can't get it to work ...

My domain is 'Curriculum'
My OU is 'Curriculum Users'
below 'Curriculum Users' I have several folders ie, 2001, 2002, 2003, etc .. and it is any user in any one of these folders which will need to be changed.
When I use this I get an error which states that a 'referal was returned from the server'

_____________________________

Steady ...
 
 
Post #: 1
 
 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"

(in reply to dave.steadman)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Reset Network Password Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts