如何编写Oracle钱包更改的脚本?
我使用Oracle钱包存储连接到的数据库的密码。我们的密码策略要求我们经常更改密码,以便我编写更改脚本。我有一个批处理文件,可以更改数据库密码自己,但我想脚本的变化,以钱包以及。问题是,在调用mkstore后必须输入钱包密码,并且该密码不能作为参数传递。是否有办法在钱包中编写凭证更改脚本?至少使用11g:如何编写Oracle钱包更改的脚本?,oracle,batch-file,sqlplus,windows-scripting,oracle11gr2,Oracle,Batch File,Sqlplus,Windows Scripting,Oracle11gr2,我使用Oracle钱包存储连接到的数据库的密码。我们的密码策略要求我们经常更改密码,以便我编写更改脚本。我有一个批处理文件,可以更改数据库密码自己,但我想脚本的变化,以钱包以及。问题是,在调用mkstore后必须输入钱包密码,并且该密码不能作为参数传递。是否有办法在钱包中编写凭证更改脚本?至少使用11g: orapki wallet change_pwd -wallet {wallet directory} \ -oldpwd {old password} -n
orapki wallet change_pwd -wallet {wallet directory} \
-oldpwd {old password} -newpwd {new password}
我还没有测试密码是否在ps-fe | grep可见的进程行中被混淆。这是我提出的Powershell脚本。要求:
Set ExecutionPolicy RemoteSigned
以管理员身份运行)Import-Module c:\oracle\WalletCreator\WASP.dll
$WalletCreated = 0
cls
Write-Host " " -foregroundcolor White -backgroundcolor DarkRed
Write-Host " Warning: This script will delete your current wallet. " -foregroundcolor White -backgroundcolor DarkRed
Write-Host " " -foregroundcolor White -backgroundcolor DarkRed
do {
#Get credentials
Write-Host " "
Write-Host " New Wallet Entry " -foregroundcolor White -backgroundcolor DarkGreen
Write-Host " To exit press return without entering anything. " -foregroundcolor White -backgroundcolor DarkGreen
$DB = Read-Host "Connection Name"
if ($DB -eq "") {
Return
}
$Username = Read-Host " Username"
if ($Username -eq "") {
Return
}
$Password = Read-Host -AsSecureString " Password"
#Convert from SecureString to String.
$BasicString = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)
$Password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BasicString)
if ($Password -eq "") {
Return
}
if ($WalletCreated -eq 0) {
#Create folder in case it doesn't exist.
md c:\oracle\Wallets -Force | Out-Null
#Delete any wallet in the folder now.
del c:\oracle\Wallets\*.* | Out-Null
#Get GUID for wallet password.
$WalletPassword = [guid]::NewGuid().toString()
$WalletPassword = $WalletPassword + "`r"
#Create Wallet.
Start-Process -FilePath mkstore -ArgumentList "-wrl c:\oracle\Wallets\ -create"
Start-Sleep -Milliseconds 500
Select-Window -ProcessName cmd | Select -First 1 | Send-Keys -keys $WalletPassword
Start-Sleep -Milliseconds 300
Select-Window -ProcessName cmd | Select -First 1 | Send-Keys -keys $WalletPassword
$WalletCreated = 1
Start-Sleep -Milliseconds 1000
}
#Create Credential.
$CC = "-wrl c:\oracle\Wallets\ -createCredential " + $DB + " "
$CC = $CC + $Username + " " + $Password
Start-Process -FilePath mkstore -ArgumentList $CC
Start-Sleep -Milliseconds 300
Select-Window -ProcessName cmd | Select -First 1 | Send-Keys -keys $WalletPassword
Start-Sleep -Milliseconds 1000
}
until ($DB -eq "")
通过echo获取存储区的passwd,以便编写脚本 回声“$passwd”| echo“WalletPasswd”| mkstore-wrl-列表凭证 这将列出输出,同样适用于所有mkstore、orapki的命令也将起作用自动热键解决方案:
; CreateWallet.ahk
#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1
Macro1:
Random, WalletPassword, 10000000000, 9999999999999999999999999
WalletPassword := WalletPassword "ExtraCharacters"
InputBox, Username, Username, Please enter your database username, , , , , , , , lriffel
InputBox, DatabasePassword, Database Password, Please enter the database password., HIDE
Run, c:\windows\system32\cmd.exe, c:\
Sleep, 500
Send, md c{:}\oracle\Wallet{enter}
Sleep, 200
Send, cd c{:}\oracle\Wallet{enter}
Sleep, 200
Send, del -s c{:}\oracle\Wallet\*.*{enter}
Sleep, 200
Send, Y{enter}
Sleep, 200
Send, mkstore -wrl c:\oracle\Wallet\ -create{enter}
Sleep, 200
Send, %WalletPassword%{enter}
Sleep, 200
Send, %WalletPassword%{enter}
Sleep, 200
Loop, Read, F:\Programs\CreateWallet\dbs.txt
{
WinHide, ahk_class ConsoleWindowClass
Sleep, 333
Send, mkstore -wrl c:\oracle\Wallet\ -createCredential %A_LoopReadLine% %Username% %DatabasePassword%{enter}
Send, %WalletPassword%{enter}
Sleep, 200
Send, cls{enter}
Sleep, 200
WinShow, ahk_class ConsoleWindowClass
Sleep, 550
}
Send, exit{enter}
MsgBox, 64, Wallet Created, Wallet Created
Return
; This script was created using Pulover's Macro Creator
; www.macrocreator.com
文件中的Windows管道工作正常。 我将钱包密码分别放在两行上,以便创建钱包以及-createCredential:
set PW=\MySecureFolder\MyWalletPasswordOn2Lines.txt
mkstore -wrl . -create < %PW%
set PW=\MySecureFolder\MyWalletPasswordOn2Lines.txt
mkstore-wrl-创建<%PW%
当然,脚本可以在开始时提示并创建文件,完成后删除文件。如果脚本异常终止,请将其放在“管理员专用”文件夹中。谢谢您的回答。如果我错了,请纠正我的错误,但这会更改钱包本身的密码,而不是钱包中的凭据。这对linux有效,但对windows无效。