我使用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. Apple Wallet动态更新值
- 2. 如何更改使用PowerShell脚本
- 3. 如何编写更改的脚本url
- 4. 我如何更改这个脚本
- 5. 如何更改SqlSyncProvider的配置脚本?
- 6. 如何将此脚本更改为
- 7. 如何将此脚本更改为OnMouseOver?
- 8. JavaScript更改脚本
- 9. Oracle sql脚本
- 10. 使shell脚本更改脚本位置
- 11. 如何编译Oracle SQL脚本?
- 12. 将oracle脚本分解为更小的脚本
- 13. 更改Apple Wallet中QR /条码的大小通行证
- 14. 更改解释bash脚本
- 15. 交换和更改脚本
- 16. Unix脚本更改目录
- 17. 更改脚本代码
- 18. 更改页脚文本
- 19. 生成更改脚本
- 20. processing.js更改脚本源
- 21. 生成脚本[ORACLE]
- 22. 如何更改Oracle中的触发器?
- 23. 如何更改Oracle XE实例的SID
- 24. 如何更改oracle中的OPTIMIZER_MODE设置?
- 25. 如何使用flash动作脚本2更改文本颜色?
- 26. Vim:如何更改缩进脚本中的文本
- 27. Apple Wallet Pass:Update Calls trigger
- 28. 如何在运行时生效/重载脚本时更改Lua脚本?
- 29. 如何刷新Chrome扩展的内容脚本,如DOM更改
- 30. Oracle更改对象?
谢谢你的答案。如果我错了,请纠正我,但这会更改钱包本身的密码而不是钱包中的凭证。 – 2011-02-18 14:58:40