3

Can I login to firebird database using a Windows user instead of using SYSDBA and MASTERKEY credential? If Yes, please let me know the way to connect to the firebird database.

I am using Delphi XE3 and Firebird 2.5. I need to authenticate user by logged in user after updating config file for "trusted" in place of default "native" as specified here: https://firebirdsql.org/file/documentation/release_notes/html/en/2_5/rnfb25-fbconf-authent.html

This is my code :

SQLConnection1.LoginPrompt := False;
//SQLConnection1.Params.add('user_name='); 
//SQLConnection1.Params.add('password='); 
SQLConnection1.Params.add('os authentication=True') ; 
SQLConnection1.Connected:= True

It still asks for credentials.

Arioch 'The
  • 15,799
  • 35
  • 62
Vinod_cmdl
  • 49
  • 9
  • 1
    Which DB client are you using - FireDAC, UniDAC, Interbase, ADO, or...? It's crucial to get a specific answer. – Victoria May 24 '17 at 00:06
  • I am using DbExpress. Need to access firebird database table data without providing user name & password. Just want to use Windows authentication to access table. Many thanks. – Vinod_cmdl May 24 '17 at 05:37
  • I used following code but asking for credentials: //SQLConnection1.Params.add('user_name='); //SQLConnection1.Params.add('password='); SQLConnection1.Params.add('os authentication=True') ; SQLConnection1.Connected:= True; – Vinod_cmdl May 24 '17 at 05:57
  • Have you set to False the LoginPrompt property of SQLConnection1 ?. – Marc Guillot May 25 '17 at 06:50
  • @MarcGuillot Yes, I set LoginPrompt to false. – Vinod_cmdl May 25 '17 at 09:28
  • I've tried to update your post because it's obviously about the client side, not server (https://stackoverflow.com/review/suggested-edits/16221614). – Victoria May 25 '17 at 13:17
  • @VictoriaMarotoSilva Ok. So at client side, please let me know how to access the firebird using Windows authentication. Many Thanks. – Vinod_cmdl May 26 '17 at 07:02
  • Have you tried not including `user_name=` and `password=`? – Mark Rotteveel May 26 '17 at 07:21
  • @MarkRotteveel, that seems to happen (notice `//` comment chars). The edit is inaccurate. The rejected one from me copied them. – Victoria May 26 '17 at 13:09
  • @MarkRotteveel I used double slash(//), means not included user_name= and password= – Vinod_cmdl May 26 '17 at 13:41
  • Then I suggest you edit your question to show the actual code. – Mark Rotteveel May 26 '17 at 14:14
  • 1
    @MarkRotteveel, I did. But it's been rejected https://stackoverflow.com/review/suggested-edits/16221614 :( I was trying to do the best with this question. – Victoria May 26 '17 at 20:54
  • 2
    @VictoriaMarotoSilva I was addressing the OP, as he should have done that when initially asking the question. I will add them myself in a sec – Mark Rotteveel May 26 '17 at 21:04
  • @MarkRotteveel, I know. I was trying to report you an incorrect review result ;) Thank you for this question update anyway. – Victoria May 26 '17 at 21:18
  • 1
    @Victoria there is no way for me to revert the already made decision, and I suppose neither can Mark, but if you really want to bring it up, I think you can do it on META.stackexchange.net – Arioch 'The Jun 01 '17 at 16:03

2 Answers2

2

(V.2.1) From Firebird 2.1 onward, Windows “Trusted User” security can be applied for authenticating Firebird users on a Windows host. The Trusted User's security context is passed to the Firebird server and, if it succeeds, it is used to determine the Firebird security user name.

Simply omitting the user and password parameters from the DPB/SPB will automatically cause Windows Trusted User authentication to be applied, in almost all cases. See the Environment section, below, for exceptions

from official documentation

Also, take a look at this question - https://dba.stackexchange.com/questions/154735/how-to-enable-windows-authentication-in-firebird-2-5

RBA
  • 12,337
  • 16
  • 79
  • 126
  • I know how to use **ISC_USER & ISC_PASSWORD**: C:\Pr~\bin>set ISC_USER=user1 C:\Pr~\bin>set ISC_PASSWORD=12345. How to add new **isc_dpb_trusted_auth** parameter to the DPB? What syntax I need to use? Thanks. – Vinod_cmdl May 26 '17 at 13:39
  • @Vinod_cmdl read the dbExpress sources and find the function that creates DPB and check what string name it uses. Unified Interbase library uses "trusted_auth" name - https://stackoverflow.com/a/44311652/976391 – Arioch 'The Jun 01 '17 at 15:41
0

If User_Name parameter of the TSQLConnection object is not set (User_Name= ), Windows Authentication connection mode is used.

Also set Authentication = mixed or trusted in firebird.conf file, and restart FirebirdServer service

If you don't set user_name and 'password' params in code (In your code have been commented), add them in design time. It's enough to add only User_Name.

If you want to use :

SQLConnection1.Params.add('user_name='); // this is enough
SQLConnection1.Params.add('password='); 

remove user_name and password params from SQLConnection.Params in design time.

Note : Do not use:

SQLConnection1.Params.Values['User_Name'] := '';

This just removes parameter from list.

Update

enter image description here

This works for me. As you see in firebird.conf Autentication is trusted only. SQLConnection params : user name and password are empty. And SQLConnection is connected.

Try to repeat this picture.

A'm using Delphi 2010.

Val Marinov
  • 2,705
  • 17
  • 22
  • "Martin, I don't want to mess with you." No worries. Anyway, I've done what I should have done in the first place and tried my code with the server's authentication = trusted. It fails to connect, giving the error message the OP quoted. So I've deleted my answer. – MartynA May 27 '17 at 18:04
  • @Val Marinov I tried but getting this message "Your user name and password are not defined. Ask your database administrator to set up a Firebird login." Any help? – Vinod_cmdl Jun 01 '17 at 09:30
  • That would stop working if he sets username and password as Windows Environment Variables. I am not sure if DBX has the required constant for enforcing trusted auth. Unified Interbase does have, though - https://stackoverflow.com/a/44311652/976391 – Arioch 'The Jun 01 '17 at 15:42
  • Do I have to add the Windows user in security2.fdb database as well or somewhere else? I am getting "Your user name and password are not defined. Ask your database administrator to set up a Firebird login.." message. – Vinod_cmdl Jun 08 '17 at 10:12
  • @Vinod_cmdl No. – Val Marinov Jun 08 '17 at 11:33
  • @Val Marinov Thanks. It worked for me. My application is using DbGo component as well. So Could anyone please help me to know how to ADOConnection1 to connect using Windows Authentication. Thanks. – Vinod_cmdl Aug 22 '17 at 12:09