#26826 - 2002-08-10 12:10 AM
Re: vbs -> Kix
|
Austin
Seasoned Scripter
Registered: 2002-01-24
Posts: 439
|
Sure thing.. I took much of this code from the board at any rate.. I dl'd the new kix and it is like at the second @error check it doesnt work.. something to do with the $SQLExe = DBExecuteSQL($objConn,$sql,)
Here is the code..
code:
;****************************************************************************** ;-Author: Austin Henderson ;-Date: 08.05.02 ;-Script: Beta Script For Password Sync ; ;-Dependancies: kix32.exe ;******************************************************************************
;Define variables...
;CODING BEGINS ;------------------------------------------------------------------------------ :TOP
CLS color w+/n :TOP $NEWPWD = guipassprompt(1,1) ;Call code to get password if ingroup ("TMT User") or ingroup ("TMW User") $ConnDSN = "DRIVER={SQL Server};SERVER=TRINITY;UID=@UserId;PWD=$GUIPassPromptOld;" $objConn = DBConnOpen($ConnDSN,,) while @error <> 0 $nul = Messagebox("- CURRENT PASSWORD INCORRECT -", "ERROR",4144) $NEWPWD = guipassprompt(1,1) ;Call code to get password $ConnDSN = "DRIVER={SQL Server};SERVER=TRINITY;UID=@UserId;PWD=$GUIPassPromptOld;" $objConn = DBConnOpen($ConnDSN,,) loop $SQL = "sp_password NULL,'$NEWPWD','@UserID'" $SQLExe = DBExecuteSQL($objConn,$sql,) if @error <> 0 $nul = Messagebox("- ERROR CONTACT ADMIN -", "ERROR",4144) else $nul = Messagebox("- PASSWORD CHANGED -", "ALERT",4160) endif $close = DBConnClose($objConn) endif
if ingroup ("GP User") $ConnDSN = "DRIVER={SQL Server};SERVER=GATES;UID=@UserId;PWD=$GUIPassPromptOld;" $objConn = DBConnOpen($ConnDSN,,) while @error <> 0 $nul = Messagebox("- CURRENT PASSWORD INCORRECT -", "ERROR",4144) $NEWPWD = guipassprompt(1,1) ;Call code to get password $ConnDSN = "DRIVER={SQL Server};SERVER=GATES;UID=@UserId;PWD=$GUIPassPromptOld;" $objConn = DBConnOpen($ConnDSN,,) loop $SQL = "sp_password NULL,'$NEWPWD','@UserID'" $SQLExe = DBExecuteSQL($objConn,$sql,) if @error <> 0 $nul = Messagebox("- ERROR CONTACT ADMIN -", "ERROR",4144) else $nul = Messagebox("- PASSWORD CHANGED -", "ALERT",4160) endif $close = DBConnClose($objConn)e($objConn) endif
;Let the functions begin ;------------------------------------------------------------------------------ Function DBConnOpen($ConnDSN, optional $ConnTimeout, optional $CmdTimeout) Dim $objConn, $adStateOpen
$adStateOpen=val('&00000001')
if vartype($ConnTimeout) $ConnTimeout=val($ConnTimeout) else $ConnTimeout=15 endif
if vartype($CmdTimeout) $CmdTimeout=val($CmdTimeout) else $CmdTimeout=30 endif
$ConnDSN=trim($ConnDSN) if not $ConnDSN exit 87 endif
$objConn = CreateObject("ADODB.Connection") if @ERROR exit @ERROR endif
$objConn.ConnectionTimeout = $ConnTimeout if @ERROR exit @ERROR endif
$objConn.CommandTimeout = $CmdTimeout if @ERROR exit @ERROR endif
$objConn.Open($ConnDSN) if @ERROR exit @ERROR endif
if not $objConn.State=$adStateOpen $objComm='' $DBConnOpen='' exit @ERROR endif $DBConnOpen=$objConn
EndFunction ;------------------------------------------------------------------------------ Function DBConnClose($objConn) Dim $adStateOpen
$adStateOpen = 1
If vartype($objConn)=9 If $objConn.State = $adStateOpen $objConn.Close() if @ERROR exit @ERROR endif EndIf $objConn='' else exit 87 endif
$DBConnClose=@ERROR EndFunction
;------------------------------------------------------------------------------ function DBExecuteSQL($objConn, $sql, optional $cmdType) dim $cmdCommand, $rsRecordset dim $adCmdUnspecified, $adCmdText, $adCmdTable, $adCmdStoredProc, $adCmdUnknown, $adCmdFile, $adCmdTableDirect
$adCmdUnspecified = -1 $adCmdText = 1 $adCmdTable = 2 $adCmdStoredProc = 4 $adCmdUnknown = 8 $adCmdFile = 256 $adCmdTableDirect = 512
if vartype($cmdType) $cmdType=val($cmdType) else $cmdType=$adCmdText endif
if vartype($objConn)<>9 or $sql='' exit 87 endif
$cmdCommand = CreateObject('ADODB.Command') if @ERROR exit @ERROR endif
$cmdCommand.ActiveConnection = $objConn if @ERROR exit @ERROR endif
$cmdCommand.CommandType = $cmdType if @ERROR exit @ERROR endif
$cmdCommand.CommandText = $sql if @ERROR exit @ERROR endif
$rsRecordset=$cmdCommand.Execute() $cmdCommand='' $rsRecordset='' if @ERROR exit @ERROR endif
$DBExecuteSQL=@ERROR
endfunction ;------------------------------------------------------------------------------ function GUIPassPrompt($case, $force, optional $title) ;This is a GUI password Prompt. ; Syntax: ; GUIPassPrompt(Case Sensetive[0/1] | force[0/1] | Optional Title ) ; Case Sensetive [0,1] ; 0 = ignore case ; 1 = all password are case sensitive ; ; Force [0,1] ; "0" will not force a password ; "1" will force the user to enter a password ; ; Title(optional) "Your title here" ; Defalut title = "Please enter your password." ; set this option to change it. ; ;Example: ; ;This will show a non case sensetive password prompt with the default title and not forced ; $password = GUIpassprompt(0,0) ; ; ;this is a forced case sensetive password prompt with the title "Enter your password" ; $password = GUIPassPrompt(1,1,"Enter your password")
DIM $title, $case, $top, $left, $height, $Width, $False, $true DIM $status, $Password1, $password2, $doc, $nul, $html
$password = "" $top = "100" $left = "200" $height = "180" $width = "275" $false = 0 $true = -1 If $title = "" $title = "SQL PASSWORD UTLILTY" endif
$html = ' <html><head> <title>$title</title> <style> <!---body{ background-color: silver; color: black;font-family: tahoma, arial; font-size: 10pt; margin: 3px "input.tbox { border: lpx black solid;}td { font: 10pt tahoma; }---> </style></head> <body scroll=no onresize="window.resizeto(240,120);"> <table align=center> <form name=frm> <tr> <td align=right>Current: </td> <td colspan=2><input id=password0 type=password value="" class=tbox></td> </tr> <tr> <td align=right>Password: </td> <td colspan=2><input id=password1 type=password value="" class=tbox></td> </tr> <tr> <td align=right>Confirm: </td> <td colspan=2><input id=password2 type=password value="" class=tbox></td> </tr> <tr> <td><input id=reset type=button value=" Submit " onclick="frm.status.value=1"><input type=hidden id=status name=status value=0></td> <td align=right><input id=close type=button value=" Cancel " onclick="frm.status.value=2"></td> </tr> </form> </table></body></html>'
:Closed_Window $ie = CreateObject("internetexplorer.application") ; Set properties and display form ... $ie.addressbar = $false $ie.menubar = $false $ie.toolbar = $false $ie.statusbar = $false $ie.resizable = $false $ie.top = $top $ie.left = $left $ie.height = $height $ie.width = $width $ie.visible = $true
$ie.navigate("about:blank")
while $ie.busy <>0 and @error = 0 loop
; Get a handle to the open document ... $doc = $ie.document $doc.write($html) while setfocus("$title") <> 0 loop
$status = $doc.GetElementById("status") $password0 = $doc.GetElementById("password0") $password1 = $doc.GetElementById("password1") $password2 = $doc.GetElementById("password2")
while @error = 0 and $status.value <> "" select case $status.value = "1" ;submit was clicked Select case $password1.value <> $password2.value $nul = Messagebox("Passwords do not match", "ERROR",4144) $password0.value = "" $password1.value = "" $password2.value = "" case $password1.value = "" or $password2.value = "" $nul = Messagebox("Blank passwords are not allowed", "ERROR",4144) $password0.value = "" $password1.value = "" $password2.value = "" case $case = 1 if $password1.value == $password2.value $GUIPassPrompt = $password1.value $GUIPassPromptOld = $password0.value $ie.quit() exit else $nul = Messagebox("Passwords do not match", "ERROR",4144) $password0.value = "" $password1.value = "" $password2.value = "" endif case $case = 0 if $password1.value = $password2.value $GUIPassPrompt = lcase($password1.value) $ie.quit() exit else $nul = Messagebox("Passwords do not match", "ERROR",4144) $password0.value = "" $password1.value = "" $password2.value = "" endif
endselect
$status.value = 0 case $status.value = "2" ;cancel was clicked if $force = "1" $nul = Messagebox("You Must Change your password!", "ERROR",4144) else $ie.quit() exit(1067) endif $status.value = 0 endselect loop if $force = "1" $nul = Messagebox("You Must Change your password!", "ERROR",4144) goto Closed_Window else $ie.quit() exit endif
endfunction
Also as I stated.. when using wkixcrypt or kixcrypt it pops a console in both new and old kix32.exe. Thank you so much for your help with this.
_________________________
Austin Henderson
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 2145 anonymous users online.
|
|
|