Disable Saved Passwords for Excel ODBC Connections
In this article
- Background: How Excel Stores ODBC Connection Passwords
- How to Disable Saved Passwords in Excel Connection Strings
- How to Disable Password Saving in ODBC DSNs
- Common Problems and Misconceptions
- Comparing Methods: DSN vs. Connection String
- Safety and Best Practices
- Alternatives to Saved Passwords
- Frequently Asked Questions
Yes, administrators can disable saved passwords for Excel ODBC connections, but the method depends on whether the connection is defined in Excel itself or in an ODBC Data Source Name (DSN) configured at the system or user level. In Excel, the option to save a password is part of the connection string, and you can remove it or enforce policies that prevent it. For DSN-based connections, the password saving behavior is controlled by the ODBC driver and the DSN configuration, which administrators can manage through registry settings or group policy.
Background: How Excel Stores ODBC Connection Passwords
When you create an ODBC connection in Excel (via Data > Get Data > From Other Sources > From ODBC, or the older Data Connection Wizard), Excel builds a connection string. That string can include a PWD= parameter. If you check the “Save password” box during setup, Excel stores the password in the connection string, which is then saved inside the workbook (for embedded connections) or in an Office Data Connection (.odc) file. This is a security concern because anyone with access to the file can read the plaintext password.
For DSN-based connections (both File DSNs and Machine DSNs), the password may be stored in the DSN definition itself, depending on the driver. For example, the SQL Server ODBC driver allows a “Save my password” checkbox when configuring a DSN. That password is stored in the Windows registry (for system DSNs) or in a file (for file DSNs).
How to Disable Saved Passwords in Excel Connection Strings
Administrators can take several steps to prevent Excel from saving passwords in connection strings:
- Remove the PWD parameter from existing connection strings: Open the connection properties in Excel (Data > Queries & Connections > right-click the query > Properties), edit the connection string, and delete the
PWD=...part. Then uncheck “Save password” if present. - Use Windows Authentication (Integrated Security): For SQL Server and many other databases, you can set
Integrated Security=SSPIorTrusted_Connection=Yesin the connection string instead of a username/password. This eliminates the need to store credentials. - Block the “Save password” option via Group Policy: Excel does not have a built-in group policy setting specifically for ODBC password saving, but you can use registry policies to disable the “Save password” checkbox in the ODBC Data Source Administrator (odbcad32.exe). The relevant registry key is
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INIfor system DSNs andHKEY_CURRENT_USER\Software\ODBC\ODBC.INIfor user DSNs. Setting theSavePasswordvalue to0(DWORD) disables the checkbox for that DSN. - Use a connection string without password and prompt at runtime: In Excel, you can configure the connection to prompt for credentials each time. In the connection properties, set “Authentication” to “Prompt for password” or leave the password blank. This forces the user to enter the password when refreshing.
How to Disable Password Saving in ODBC DSNs
For DSNs, the process varies by driver and Windows version:
- Open the ODBC Data Source Administrator (type “ODBC” in Start menu).
- Select the DSN you want to modify (User DSN or System DSN) and click “Configure”.
- Look for a “Save password” checkbox or a “Password” field. Uncheck “Save password” or clear the password field.
- If you are using a file DSN, the password is stored in the .dsn file. Edit the file in a text editor and remove the
PWD=line.
Administrators can also enforce this via registry by setting the SavePassword value to 0 under the DSN’s registry key. For system DSNs, this is under HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\. For user DSNs, it is under HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\. This prevents the checkbox from being checked in the UI, but note that some drivers may not respect this setting.
Common Problems and Misconceptions
A frequent misconception is that removing the password from the connection string in Excel will break the connection. In reality, if the database requires authentication, the user will be prompted for credentials. This is often desirable for security but can be inconvenient if you want unattended refreshes.
Another issue is that even if you disable the “Save password” checkbox in the DSN, Excel may still store the password if you enter it in the connection dialog. The only way to ensure it is not saved is to leave the password field blank and rely on Windows authentication or a prompt.
Also, note that some ODBC drivers (like the older Microsoft Access Driver) may not support Windows authentication, so you must use a password. In that case, you can store the password in a secure location outside the workbook, such as a Windows credential manager, but Excel does not natively integrate with that.
Comparing Methods: DSN vs. Connection String
There are two main approaches to ODBC connections in Excel:
- DSN-based: The connection uses a pre-defined DSN. The password may be stored in the DSN. Administrators can control this centrally by modifying the DSN registry entries.
- DSN-less connection string: The connection string is embedded directly in the workbook or .odc file. This is harder to control centrally because the password is stored in the file itself.
For administrators, DSN-based connections are easier to manage because you can change the DSN settings on each machine or via group policy. However, DSN-less connections are more portable. The choice depends on your environment and security requirements.
Safety and Best Practices
Storing passwords in Excel workbooks or DSNs is risky because they are often stored in plaintext. Best practices include:
- Use Windows Integrated Security whenever possible.
- If you must use SQL authentication, do not save the password; prompt the user each time.
- If you need unattended refreshes, consider using a service account with a separate secure credential store (e.g., Windows Credential Manager, but Excel does not use it natively).
- Regularly audit your workbooks for connection strings that contain passwords. You can search for
PWD=in the connection XML.
Alternatives to Saved Passwords
If you need to automate Excel refreshes without prompting, consider these alternatives:
- Power Query with Windows Authentication: Use Windows authentication in the connection string and run the refresh under a user account that has access to the database.
- Power Automate or VBA with secure credential storage: Use a VBA macro that reads credentials from a secure file or environment variable and builds the connection string at runtime.
- Use a SQL Server linked server or an intermediate layer: Instead of connecting directly from Excel, create a view or stored procedure that uses Windows authentication, and connect to that from Excel.
Frequently Asked Questions
Can I disable the “Save password” option for all ODBC connections on a computer?
There is no single global setting in Windows to disable password saving for all ODBC connections. You must configure each DSN individually or use registry policies to set the SavePassword value to 0 for each DSN. For Excel-specific connection strings, you can only control what is saved in the workbook.
Will removing the password from the connection string cause Excel to prompt every time?
Yes, if the database requires authentication and no password is in the connection string, Excel will prompt the user for credentials when refreshing the connection. This is the intended behavior if you want to avoid storing passwords.
Does Excel store the password in the workbook file itself?
Yes, if you check “Save password” when creating the connection, the password is embedded in the connection string, which is stored in the workbook (or in the .odc file if you export the connection). This is a security risk because the file can be opened with a text editor to reveal the password.
Can I use Group Policy to prevent users from saving passwords in Excel ODBC connections?
There is no specific Group Policy setting for Excel’s ODBC password saving. However, you can use Group Policy to enforce registry settings for ODBC DSNs, and you can also restrict users’ ability to create new DSNs by removing their access to the ODBC Data Source Administrator. For connection strings inside Excel, you would need to rely on user training and periodic audits.
What is the difference between a User DSN and a System DSN regarding password saving?
User DSNs are stored in the current user’s registry and are only visible to that user. System DSNs are stored in the machine’s registry and are visible to all users. Both can store passwords, but system DSNs are more accessible to other users on the same machine, so it is especially important to avoid saving passwords there.