Windows Authentication in Firebird 2.5

本小妞迷上赌 提交于 2020-01-14 14:38:28

问题


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.


回答1:


(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




回答2:


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

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.



来源:https://stackoverflow.com/questions/44135982/windows-authentication-in-firebird-2-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!