Is switching authentication methods possible?

Posts   
 
    
JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 25-Apr-2007 13:03:23   

I know changing databases is possible, I do that with a key in my App.Config at compile time, but is changing authentication methods at run time possible?

I am using Windows authentication at the moment but I want my users to be able to use the software over a VPN from a computer that is not strictly connected to the network in a nice windows integrated way.

Would it be possible to first try to connect, and if it fails, switch to manual authentication and / or ask for a username and password and pretend to be using windows authentication in a normal way or something like that?

I hope that makes sense, I fear I may not have explained myself very well! smile

JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 25-Apr-2007 14:09:46   

Sorry, should have mentioned.

This project is VB.NET 2005 / LLBLGen Pro 2.0 / Self Servicing.

Also, I just need to set the authentication at startup, I don't need to change it throughout.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-Apr-2007 17:01:23   

You are speaking about database authentication, right?

For this you can do whatever you want and at the end of the day LLBLGen Pro will need from you the connection string which you can supply to the DbUtils.

The DbUtils class lets you set the global connection string to use for every connection to the database. This setting overrides the connection string read from the appSettings section in the .config file. Once the setting is set, every connection to the database uses the set connection string. You set the connection string to use at runtime using the following code:

DbUtils.ActualConnectionString = "Datasource=myserver;....";

If you want to make the application use the connection string defined in the config file again, simply set the ActualConnectionString property to string.Empty.

Just take care that this will set the connectionString globaly, which might not be what you want, so maybe you will need to switch to the Adapter model, to set the connectionString per call, so you can store each user's connectionString in a hashtable or something and use each user's connection string to perform his actions.

JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 25-Apr-2007 17:26:00   

That looks promising, thanks.

JMitchell avatar
JMitchell
User
Posts: 128
Joined: 01-Sep-2006
# Posted on: 25-Apr-2007 18:00:21   

I've been looking into this a little more and, whiel it looks like Walaa's suggestion answere the question I asked, it doesn't solve my problem!

What I need is the ability to provide my windows authentication credentials manually rather than picking them up from the user that is currently logged in to the PC.

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 25-Apr-2007 18:18:14   

As far as I know, Windows Authentication will only work if the computer that a user is logged into is member of the domain that the SQL server is in or a member of a domain trusted by the domain the SQL Server is in.

Otherwise you will need to use SQL Server authentication and have the user enter a SQL Server username and password and embed that in the connection string.

One alternative is to use a middle tier between the client PC and the SQL Server that handles the client authentication and authorization and brokers the requests to the SQL Server. The client authenticates to the middle tier and the middle tier uses a separate authentication to the SQL Server.

Remoting and/or Web Services come to mind...