Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Change Password VBScript with HTML Form

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Change Password VBScript with HTML Form
  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 >>
 Change Password VBScript with HTML Form - 10/18/2006 12:58:13 AM   
  Ivo

 

Posts: 4
Score: 0
Joined: 10/18/2006
Status: offline
Hi everyone

the idea of what I need is an Html Form so users can change their Outlook Password cause the Exchange Server is not hosted with the domain localy (don`t ask me why). So everytime an user changes his Logon Password he wants to change his Outlook Password too on the Exchange Server.

I created an HTML Form and also an VBSCript that changes the Password. The VBScript is working fine standalone, but together with the html Form I always get an error that "ActiveX component can`t create object". Can somebody help me?

Here is the Script:

<html>
<form>
<h1>Change Password</h1>
<table border="0" cellpadding="3" cellspacing="3">
<tr>
<td>User Name:</td>
<td><INPUT type="text" name="Account"><BR></td>
</tr>
<tr>
<td>Old Password :</td>
<td><INPUT type="password" name="OldPassword"><BR></td>
</tr>
<tr>
<td>New Password :</td>
<td><INPUT type="password" name="newPassword"><BR></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><INPUT type="password" name="confirmPassword"><BR></td>
</tr>
<tr>
<td><input type=button id=ChangePassword Value="Change Password"></td>
</tr>
</table>
</form>

<--------------- VBSCript -------------------->

<script type="text/vbscript">

Sub ChangePassword_OnClick

dim oldPassword, newPassword, Account, confirmPassword
Dim WSHNet, UserObject, oWinNT, domain

Set WshShell = WScript.CreateObject("WScript.Shell")
'Account = "xptest02"
'oldPassword = "Test11!"
'newPassword  = "Test22!"
'confirmPassword  = "Test22!"
domain = "10.8.10.2"


if newPassword <> confirmPassword then
Msgbox "The confirmation password does not match the new password"
exit sub
end if

Set WSHNet = WScript.CreateObject("WScript.Network")
Set oWinNT = GetObject("WinNT:")
Set UserObject = oWinNT.OpenDSObject("WinNT://" & domain & "/" & Account, Account, oldPassword , 1)
if err <> 0 Then
Msgbox "User '" & Account & "' on '" & domain & " not found."
showError "Error #" & err.number & ": " & err.description
exit sub
end if


UserObject.changePassword oldPassword, newPassword

if err <> 0 then
Msgbox "Could not change password for user '" & Account & " You may not have sufficient privileges, " &_
"or you may have input an incorrect current password."
exit sub
end if
Msgbox "Password changed"

' msgbox err.number & " " & err.description
Set WSHNet = Nothing
Set UserObject = Nothing
End Sub
</script>
</html>
 
 
Post #: 1
 
 RE: Change Password VBScript with HTML Form - 10/18/2006 12:59:57 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
WScript is not available to HTAs. Just use CreateObject instead of WScript.Create Object.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Ivo)
 
 
Post #: 2
 
 RE: Change Password VBScript with HTML Form - 10/18/2006 1:06:26 AM   
  Ivo

 

Posts: 4
Score: 0
Joined: 10/18/2006
Status: offline
Tnx that was quick :-)

I did, now i get the error Active X Component can?t create object "GetObject"

(in reply to Ivo)
 
 
Post #: 3
 
 RE: Change Password VBScript with HTML Form - 10/18/2006 2:07:17 AM   
  ebgreen


Posts: 4970
Score: 31
Joined: 7/12/2005
Status: offline
There is a good chance that is a security issue. I don't know all the security issues around HTAs, but google does.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Ivo)
 
 
Post #: 4
 
 RE: Change Password VBScript with HTML Form - 10/18/2006 3:48:14 AM   
  TNO


Posts: 1247
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Somewhere deep in my pockets somewhere I have something that will make  WScript available to hta's

....lets see

(has a habit of writing replies before having an answer )

Here it is. The CLSID of the scripting host object. This used to be a big issue back when IE5 was about and scriptlets were the new kid on the block causing security issues all-round

<object id='wsh' classid='clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B'></object>
<button onclick="wsh.Run('c:\\FormFlow\\DFFILL.EXE')">command</button>

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Change Password VBScript with HTML Form - 10/18/2006 6:11:48 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Maybe I missed it, but is this for HTA or HTML?

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to TNO)
 
 
Post #: 6
 
 RE: Change Password VBScript with HTML Form - 10/18/2006 11:52:34 PM   
  Ivo

 

Posts: 4
Score: 0
Joined: 10/18/2006
Status: offline
it was ment to be in html, but if it works in hta that would be ok too.

@TNO

what should i do with
<object id='wsh' classid='clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B'></object>
<button onclick="wsh.Run('c:\\FormFlow\\DFFILL.EXE')">command</button>

i?m not such advanced

(in reply to Ivo)
 
 
Post #: 7
 
 RE: Change Password VBScript with HTML Form - 10/19/2006 1:11:54 AM   
  TNO


Posts: 1247
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Just place

<object id='wsh' classid='clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B'></object>

Anywhere inside the <body></body>

Everything in your script that requires WScript replace with wsh

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to Ivo)
 
 
Post #: 8
 
 RE: Change Password VBScript with HTML Form - 10/22/2006 7:19:44 PM   
  Ivo

 

Posts: 4
Score: 0
Joined: 10/18/2006
Status: offline
Hmm...... Something is still wrong. now i get an error " Line 38, Object  required 'wsh' ", even i pasted <object id='wsh' classid='clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B'></object> as u said.

Line 38 is Set WshShell = wsh.CreateObject("wsh.Shell")

----------------------------------------------
<html>
<body>
<form>
<h1>Change Password</h1>
<table border="0" cellpadding="3" cellspacing="3">
<tr>
 <td>User Name:</td>
 <td><INPUT type="text" name="Account"><BR></td>
</tr>
<tr>
 <td>Old Password :</td>
 <td><INPUT type="password" name="OldPassword"><BR></td>
</tr>
<tr>
 <td>New Password :</td>
 <td><INPUT type="password" name="newPassword"><BR></td>
</tr>
<tr>
 <td>Confirm Password:</td>
 <td><INPUT type="password" name="confirmPassword"><BR></td>
</tr>
<tr>
<td><input type=button id=ChangePassword Value="Change Password"></td>
</tr>
<object id='wsh' classid='clsid:F935DC22-1CF0-11D0-ADB9-00C04FD58A0B'></object>
</table>
</form>
</body>
<--------------- VBSCript -------------------->
<script type="text/vbscript">
Sub ChangePassword_OnClick
dim oldPassword, newPassword, Account, confirmPassword, wsh
Dim WSHNet, WshShell, UserObject, oWinNT, domain
Set WshShell = wsh.CreateObject("wsh.Shell")
'Account = Inputbox("Geben Sie Ihren Outlook Benutzernamen ein","Eingabe")
'oldPassword = Inputbox("Geben Sie das alte Kennwort ein","Eingabe")
'newPassword  = Inputbox("Geben Sie das neue Kennwort ein","Eingabe")
'confirmPassword  = Inputbox("Bestätigen Sie das neue Kennwort ","Eingabe")
domain = "10.8.10.2"

if newPassword <> confirmPassword then
   Msgbox  "The confirmation password does not match the new password"
exit sub
end if
       Set WSHNet = wsh.CreateObject("wsh.Network")
       Set oWinNT = GetObject("WinNT:")
       Set UserObject = oWinNT.OpenDSObject("WinNT://" & domain & "/" & Account, Account, oldPassword , 1)
if err <> 0 Then
   Msgbox "User '" & Account & "' on '" & domain & " not found."
   showError "Error #" & err.number & ": "  & err.description
   exit sub
end if
 
 UserObject.changePassword oldPassword, newPassword
 
  if err <> 0 then
   Msgbox "Could not change password for user '" & Account & " You may not have sufficient privileges, " &_
"or you may have input an incorrect current password."
   exit sub
end if
   Msgbox "Passwort erfolgreich geändert"
  
' msgbox err.number & " " & err.description
       Set WSHNet = Nothing
       Set UserObject = Nothing
End Sub
</script>
</html>

(in reply to TNO)
 
 
Post #: 9
 
 RE: Change Password VBScript with HTML Form - 10/22/2006 9:15:17 PM   
  TNO


Posts: 1247
Score: 10
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Interesting. I'm not sure if there was a security updatre that completely disabled this control or what.
Try ebgreen's idea to see if it will work.

CreateObject("WScript.Shell")

Put  <script></script> in the head tags, and delete the <object> tab

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to Ivo)
 
 
Post #: 10
 
 
 
  

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 >> Change Password VBScript with HTML Form 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