Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

dotnet 7 set AUTHENTICATION_SERVICES

MartinMNov 16 2022

I have an old dotnet 4.8 app that uses certificate validation to authenticate the user. I'm trying to update the application to dotnet 7.
In the dotnet 4.x app, I have an app.config that looks like this...

``

<connectionStrings>
	  <add name="connStr1" connectionString="Data Source=Alias1;User ID=/;" providerName="System.Data.OracleClient" />
	<add name="connStr2" connectionString="Data Source=Alias2;User ID=/;" providerName="System.Data.OracleClient" />
  </connectionStrings>
  <oracle.manageddataaccess.client>
	<version number="*">
		<dataSources>
			<dataSource alias="Alias1" descriptor="        
						(DESCRIPTION=         
							(ADDRESS=          
								(PROTOCOL=TCPS)          
								(HOST=servername)          
								(PORT=2484)         
							)
							(CONNECT_DATA=          
								(SERVICE_NAME=sid)         
							)
							(SECURITY=          
								(MY_WALLET_DIRECTORY=Wallets\User1)
								(SSL_SERVER_CERT_DN='xxxxxx')							
							)
						)" />
			<dataSource alias="Alias2" descriptor="        
						(DESCRIPTION=         
							(ADDRESS=          
								(PROTOCOL=TCPS)          
								(HOST=servername)          
								(PORT=2484)         
							)
							(CONNECT_DATA=          
								(SERVICE_NAME=sid)         
							)
							(SECURITY=          
								(MY_WALLET_DIRECTORY=Wallets\User2)   
								(SSL_SERVER_CERT_DN='xxxxxx')
							)                
						)" />
	  </dataSources>
	  <settings>
		<setting name="SQLNET.AUTHENTICATION_SERVICES" value="(TCPS)" />
		<setting name="SSL_SERVER_DN_MATCH" value="TRUE" />
	  </settings>
	</version>
  </oracle.manageddataaccess.client>

``
So when I connect to the DB using connStr1, I am DB user 1. When I connect to the DB using connStr2, I am DB user 2.

How can I do this with dotnet 7 with an appsettings.json file for the configuration? Of if it will be better to not put these settings in the config file, is there a way to do it in C#?

Comments
Post Details
Added on Nov 16 2022
7 comments
531 views