我使用Oracle錢包來存儲我連接到的數據庫的密碼。我們的密碼政策要求我們經常更改我們的密碼,以便我想對這些更改進行編寫。我有一個批處理文件,可以自己更改數據庫密碼,但我想將更改腳本編寫到錢包。問題是必須在調用mkstore後輸入錢包密碼,並且密碼不能作爲參數傳遞。有沒有一種方法來編寫錢包中的憑證更改腳本?如何腳本Oracle Wallet更改?
2
A
回答
1
這是我想出的Powershell腳本。要求:
- 已安裝PowerShell。
- 啓用腳本(
Set-ExecutionPolicy RemoteSigned
以管理員身份運行)。 - 該腳本位於c:\ oracle \ WalletCreator中。
- 來自Windows Automation Snapin for PowerShell的Wasp.dll位於腳本文件夾中。
錢包將在c:\ oracle \ Wallets中創建。這是腳本。
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 "")
1
11g版本至少爲:
orapki wallet change_pwd -wallet {wallet directory} \
-oldpwd {old password} -newpwd {new password}
我沒有測試過是否密碼獲得在生產線從PS -fe可見混淆| grep的。
1
通過echo獲取商店的密碼,以便您可以編寫腳本。
echo「$ passwd」|
echo「WalletPasswd」| mkstore -wrl。 -listCredential
這將列出輸出,同樣命令所有mkstore,orapki將工作
0
AutoHotkey的解決方案:
; 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
相關問題
- 1. 如何通過Oracle Wallet使用PHP?
- 2. Apple Wallet動態更新值
- 3. 使用來自OCI的Oracle Wallet認證
- 4. 如何更改腳本中的變量?
- 5. 我如何更改這個腳本
- 6. 如何編寫更改的腳本url
- 7. 如何更改使用PowerShell腳本
- 8. 如何將此腳本更改爲
- 9. 如何更改Scala腳本的目錄?
- 10. 如何更改SqlSyncProvider的配置腳本?
- 11. 如何將此腳本更改爲OnMouseOver?
- 12. AWK更改腳本
- 13. JavaScript更改腳本
- 14. Oracle sql腳本
- 15. 使shell腳本更改腳本位置
- 16. 將PING腳本更改爲TELNET腳本?
- 17. 使用Oracle sqlplus訪問Oracle Wallet Instant客戶端
- 18. 使用Oracle Wallet驗證從Spring-jdbc連接到Oracle數據庫
- 19. 將用戶更改爲oracle並在shell腳本中運行sql
- 20. oracle中腳本的導出更改(使用Toad?)
- 21. 如何編譯Oracle SQL腳本?
- 22. 將oracle腳本分解爲更小的腳本
- 23. createStartScripts更改腳本名稱
- 24. 更改腳本的JavaScript
- 25. processing.js更改腳本源
- 26. PyCharm自動更改腳本
- 27. 更改腳本代碼
- 28. 交換和更改腳本
- 29. Adobe Photoshop腳本更改
- 30. 生成更改腳本
謝謝你的答案。如果我錯了,請糾正我,但這會更改錢包本身的密碼而不是錢包中的憑證。 – 2011-02-18 14:58:40