FB 3 embedded Missing security context

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

FB 3 embedded Missing security context

Daniele Barzotti
Hi,

I'm trying to create a \ connect to FB 3 embedded but I get a DbException:

{System.Data.Common.DbException} =
{"Missing security context for D:\\...path...\\RADIOS.FDB"}

What I'm missing?

My code is:

      var currentDirectory =
        Path.GetDirectoryName(GetCurrentProcess().MainModule.FileName);

      string dbPath = Path.Combine(currentDirectory, "Radios.fdb");

      var connectionString = new FbConnectionStringBuilder
      {
        Database = dbPath,
        ServerType = FbServerType.Embedded,
        UserID = "sysdba",
        Password = "masterkey",
        ClientLibrary = "fbclient.dll"
      }.ToString();

      try
      {
        _Conn = new FbConnection();
        _Conn.ConnectionString = connectionString;
        _Conn.InfoMessage += _Conn_InfoMessage;
        _Conn.StateChange += _Conn_StateChange;

        if (!File.Exists(dbPath))
        {
          FbConnection.CreateDatabase(_Conn.ConnectionString);
          _Conn.Open();

          FbCommand cmd = new FbCommand(DbDefinition, _Conn);
          var tr = _Conn.BeginTransaction();
          cmd.ExecuteNonQuery();
          tr.Commit();

        }
        else
          _Conn.Open();

        LoadData();
      }
      catch (FbException fex)
      {
        _logger.Error(fex, "MainModel error");
        throw fex;
      }
      catch (Exception ex)
      {
        _logger.Error(ex, "MainModel error");
        throw ex;
      }

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: FB 3 embedded Missing security context

Jiří Činčura-2
Check the RN, the "Security" chapter. 

-- 
Mgr. Jiří Činčura
Independent IT Specialist


On Wed, Feb 1, 2017, at 15:58, Daniele Barzotti wrote:
> Hi,
>
> I'm trying to create a \ connect to FB 3 embedded but I get a
> DbException:
>
> {System.Data.Common.DbException} =
> {"Missing security context for D:\\...path...\\RADIOS.FDB"}
>
> What I'm missing?
>
> My code is:
>
>       var currentDirectory =
>         Path.GetDirectoryName(GetCurrentProcess().MainModule.FileName);
>
>       string dbPath = Path.Combine(currentDirectory, "Radios.fdb");
>
>       var connectionString = new FbConnectionStringBuilder
>       {
>         Database = dbPath,
>         ServerType = FbServerType.Embedded,
>         UserID = "sysdba",
>         Password = "masterkey",
>         ClientLibrary = "fbclient.dll"
>       }.ToString();
>
>       try
>       {
>         _Conn = new FbConnection();
>         _Conn.ConnectionString = connectionString;
>         _Conn.InfoMessage += _Conn_InfoMessage;
>         _Conn.StateChange += _Conn_StateChange;
>
>         if (!File.Exists(dbPath))
>         {
>           FbConnection.CreateDatabase(_Conn.ConnectionString);
>           _Conn.Open();
>
>           FbCommand cmd = new FbCommand(DbDefinition, _Conn);
>           var tr = _Conn.BeginTransaction();
>           cmd.ExecuteNonQuery();
>           tr.Commit();
>
>         }
>         else
>           _Conn.Open();
>
>         LoadData();
>       }
>       catch (FbException fex)
>       {
>         _logger.Error(fex, "MainModel error");
>         throw fex;
>       }
>       catch (Exception ex)
>       {
>         _logger.Error(ex, "MainModel error");
>         throw ex;
>       }
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Firebird-net-provider mailing list
> https://lists.sourceforge.net/lists/listinfo/firebird-net-provider


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: FB 3 embedded Missing security context

Daniele Barzotti
Thanks for the reply,

maybe I misunderstood something, sorry, this is the first time I'm using
the 3.x embedded

I create a Databases.conf in my db folder:

radiodb = D:\path_to_db\radios.fdb
{
  RemoteAccess = false
  SecurityDatabase = radiodb
}

And now I get:

{System.Data.Common.DbException} =
{"Unable to complete network request to host \"xnet://Global\\FIREBIRD\"."}


I try to follow the RN instructions and I create a brand new DB with isql...

> isql -user sysdba
SQL> create database 'radios.fdb';

Follow the steps to create a password for sysdba:

SQL> connect radios;
SQL> create user sysdba password 'my_password';

I get a violation of PRIMARY KEY constraint INTER_2 on table PLG$USERS
because PLG$USER_NAME" = 'SYSDBA'

What I miss?


Il 01/02/2017 21:50, Jiří Činčura ha scritto:

> Check the RN, the "Security" chapter.
>
> --
> Mgr. Jiří Činčura
> Independent IT Specialist
>
>
> On Wed, Feb 1, 2017, at 15:58, Daniele Barzotti wrote:
>> Hi,
>>
>> I'm trying to create a \ connect to FB 3 embedded but I get a
>> DbException:
>>
>> {System.Data.Common.DbException} =
>> {"Missing security context for D:\\...path...\\RADIOS.FDB"}
>>
>> What I'm missing?
>>
>> My code is:
>>
>>       var currentDirectory =
>>         Path.GetDirectoryName(GetCurrentProcess().MainModule.FileName);
>>
>>       string dbPath = Path.Combine(currentDirectory, "Radios.fdb");
>>
>>       var connectionString = new FbConnectionStringBuilder
>>       {
>>         Database = dbPath,
>>         ServerType = FbServerType.Embedded,
>>         UserID = "sysdba",
>>         Password = "masterkey",
>>         ClientLibrary = "fbclient.dll"
>>       }.ToString();
>>
>>       try
>>       {
>>         _Conn = new FbConnection();
>>         _Conn.ConnectionString = connectionString;
>>         _Conn.InfoMessage += _Conn_InfoMessage;
>>         _Conn.StateChange += _Conn_StateChange;
>>
>>         if (!File.Exists(dbPath))
>>         {
>>           FbConnection.CreateDatabase(_Conn.ConnectionString);
>>           _Conn.Open();
>>
>>           FbCommand cmd = new FbCommand(DbDefinition, _Conn);
>>           var tr = _Conn.BeginTransaction();
>>           cmd.ExecuteNonQuery();
>>           tr.Commit();
>>
>>         }
>>         else
>>           _Conn.Open();
>>
>>         LoadData();
>>       }
>>       catch (FbException fex)
>>       {
>>         _logger.Error(fex, "MainModel error");
>>         throw fex;
>>       }
>>       catch (Exception ex)
>>       {
>>         _logger.Error(ex, "MainModel error");
>>         throw ex;
>>       }


---
Questa e-mail è stata controllata per individuare virus con Avast antivirus.
https://www.avast.com/antivirus


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider
Reply | Threaded
Open this post in threaded view
|

Re: FB 3 embedded Missing security context

Jiří Činčura-2
You need to create mapping (based on your first error):
https://www.firebirdsql.org/file/documentation/release_notes/html/en/3_0/rnfb30-security-mapping.html

--
Mgr. Jiří Činčura
Independent IT Specialist


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Firebird-net-provider mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider