Repository navigation
Closed as not planned
Labels
Description
I encountered a Problem while trying to connect to embedded Firebird 2.5.9 on Linux.
You need to specify a UserId and Password in the connectionstring, else TrustedAuth is used, which is not supported by embedded.
But when you pass a UserId or Password to the embedded Server, it tries to check those in the security2.fdb. But since Authentication is not set up in embedded mode you get the following error:
Unhandled exception. FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
---> FirebirdSql.Data.Common.IscException: Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
at FirebirdSql.Data.Client.Native.StatusVectorHelper.ProcessStatusVector(IntPtr[] statusVector, Charset charset, Action`1 warningMessage)
at FirebirdSql.Data.Client.Native.FesDatabase.ProcessStatusVector(Charset charset)
at FirebirdSql.Data.Client.Native.FesDatabase.AttachAsync(DatabaseParameterBufferBase dpb, String database, Byte[] cryptKey, CancellationToken cancellationToken)
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.ConnectAsync(CancellationToken cancellationToken)
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.ConnectAsync(CancellationToken cancellationToken)
at FirebirdSql.Data.FirebirdClient.FbConnection.OpenAsync(CancellationToken cancellationToken)
at Program.<Main>$(String[] args) in /test/app/Program.cs:line 21
at Program.<Main>$(String[] args) in /test/app/Program.cs:line 25
at Program.<Main>(String[] args)
In order to fix this problem, I suggest to add an additional check if it is embedded ServerType in the Connect and ConnectAsync Methods:
public async Task ConnectAsync(CancellationToken cancellationToken = default)
{
if (!Charset.TryGetByName(_options.Charset, out var charset))
throw new ArgumentException("Invalid character set specified.");
try
{
_db = await ClientFactory.CreateDatabaseAsync(_options, cancellationToken).ConfigureAwait(false);
var dpb = BuildDpb(_db, _options);
if (string.IsNullOrEmpty(_options.UserID) && string.IsNullOrEmpty(_options.Password) && _options.ServerType == FbServerType.Default)
{
await _db.AttachWithTrustedAuthAsync(dpb, _options.Database, _options.CryptKey, cancellationToken).ConfigureAwait(false);
}
else
{
await _db.AttachAsync(dpb, _options.Database, _options.CryptKey, cancellationToken).ConfigureAwait(false);
}
}
catch (IscException ex)
{
throw FbException.Create(ex);
}
}Like this you don't need to specify a UserId and Password in the connection string when connecting to Firebird embedded.
Activity
cincuranet commentedon Jul 7, 2022
That's not correct. Auth still applies in Embedded, i.e. you can connect as user
Fooand that user does not have permissions for tableT, and that works/must work.mrotteveel commentedon Jul 7, 2022
To clarify: in Firebird 2.5 and earlier on Linux, authentication against the security database is applied even in Embedded mode. In Firebird 3.0 and higher, authentication against the security database is no longer used for Embedded mode (just like for Windows in earlier Firebird versions)
rKuettel commentedon Jul 7, 2022
But when I use any combination of username/password I get the Error described in the Issue and therefore can't connect to the Database.
cincuranet commentedon Jul 7, 2022
As Mark pointed out on with 2.5 and Linux (I missed you're running on Linux) the security DB is still used.
rKuettel commentedon Jul 7, 2022
This means, the connection should work when I set up a User and Password with gsec, right?
Because I tried that but still got the same error.
The only way I managed to establish connection was without using a username/password which required the suggested change.
cincuranet commentedon Jul 7, 2022
Yes. Or
SYSDBA/masterkey(which in FB2.5 was available by default).rKuettel commentedon Jul 7, 2022
Using
SYSDBA/masterkeyor any other user I set up caused the same error.cincuranet commentedon Jul 7, 2022
It's better if you take this into firebird-support list.
rKuettel commentedon Jul 7, 2022
I just found another solution for my Problem.
Setting the environment variables ISC_USER and ISC_PASSWORD and using those credentials solved my problem.
But I'm still a bit confused why it also worked when passing no User/Pass (using my changes)
But anyway thanks for your time and help :)