You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VB脚本中Oracle OLE DB如何实现无密码连接?Oracle Wallet集成咨询

Hey there! Let's walk through how to integrate Oracle Wallet with your VB Script for password-less database access, plus a couple other solid options since OS authentication isn't on the table.

Using Oracle Wallet with OraOLEDB.Oracle

Since your server already has Oracle Wallet deployed, the main steps are configuring your client (the machine running the VB Script) and updating your connection string:

  1. Client-side configuration
    First, ensure your Oracle Client (or Instant Client) is set up to use the wallet:

    • Locate your sqlnet.ora file (typically in ORACLE_HOME/network/admin or %APPDATA%\Oracle\network\admin for Windows) and add these lines:
      SQLNET.WALLET_OVERRIDE = TRUE
      WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = C:\path\to\your\wallet)))
      
    • Keep your existing tnsnames.ora entry for MyOracleDB—it should still point to your database as before.
    • Double-check that the wallet contains the correct credentials for MyOracleDB. If not, use the mkstore command to add them:
      mkstore -wrl C:\path\to\wallet -createCredential MyOracleDB myUsername myPassword
      
  2. Update your VB Script connection string
    Remove the User Id and Password parameters entirely. Your script will now look like this:

    Dim conn
    Set conn = CreateObject("ADODB.Connection")
    ' No username/password needed—wallet handles authentication
    conn.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;"
    conn.Open
    

    The OraOLEDB provider will automatically pull credentials from the wallet for the specified data source. You can test this first with sqlplus /@MyOracleDB to confirm the wallet works without a password.

Alternative Password-Less Options

If you need backup solutions beyond the wallet, here are two viable approaches:

1. External Authentication (DBA-configured)

If your Oracle database is set up to support external authentication (like SSL certificates or third-party identity providers), you can use this with OraOLEDB. Adjust your connection string to enable external auth:

Dim conn
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;External Authentication=True;"
conn.Open

Note: This requires your DBA to configure the database to accept external authentication for your user account—reach out to them to set this up first.

2. Encrypted Local Credential Storage

Store your encrypted password in a secure local file, then decrypt it at runtime in your script. Use Windows' built-in crypto APIs to avoid rolling your own encryption (which is risky). Here's a simplified example:

' Decrypts a stored password using Windows CAPICOM
Function DecryptPassword(encryptedData)
    Dim objCrypt
    Set objCrypt = CreateObject("CAPICOM.EncryptedData")
    objCrypt.Decode(encryptedData)
    DecryptPassword = objCrypt.Content
End Function

' Read encrypted password from a restricted file
Dim fso, file, encryptedPass
Set fso = CreateObject("Scripting.FileSystemObject")
' Ensure this file has strict permissions (only your script user can read it!)
Set file = fso.OpenTextFile("C:\secure\encrypted_cred.txt", 1)
encryptedPass = file.ReadAll
file.Close

' Build connection string with decrypted password
Dim conn
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=" & DecryptPassword(encryptedPass) & ";"
conn.Open

Critical: Lock down the encrypted file with NTFS permissions so only the user running the script can access it—this prevents unauthorized users from reading the encrypted data.

Quick Checks Before Deploying

  • For the wallet approach, confirm the client machine can access the wallet directory (no permission issues).
  • If using Instant Client, make sure the wallet files are placed in the correct location (usually the same folder as the Instant Client binaries, or reference it in sqlnet.ora).

内容的提问来源于stack exchange,提问作者Alexis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:15:07