Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Firebird de nasıl yapabilirim ?
#1
Arkadaşlar merhaba,
  
  dbConn.DriverName := 'MSSQL';
  iniFile := TIniFile.Create(GetCurrentDir + '\DBConfig.ini');
  version_ := GetVerInfo(Application.ExeName);

  with dbConn do
    begin
      Params.Add('Server='+Decrypt(iniFile.ReadString('INFO', 'serverName', '')) );
      Params.Add('Database='+Decrypt(iniFile.ReadString('INFO', 'database', '')) );
      Params.Add('User_name='+Decrypt(iniFile.ReadString('INFO', 'userName', '')) );
      Params.Add('Password='+Decrypt(iniFile.ReadString('INFO', 'password', '')));
      Params.Add('Workstation=' + GetHostName );
      Params.Add('Applicationname=' + 'BYM_TCR'+ StringReplace(version_, '.', '', [rfReplaceAll]) +
                             '-' + GetHostName + '-'+GetPID(Application.ExeName) +'-'+GetPlatform );
    end;

bu parametreleri kullanarak FDConnection ile MSSQL e bağlantıyı sağlıyorum, gerektiğinde

SELECT session_id, login_name, host_name, program_name, memory_usage
FROM sys.dm_exec_sessions
WHERE (is_user_process = 1) and (program_name LIKE 'BYM_TCR%') 

session_id | login_name | host_name  | program_name                         | status     | memory_usage
-------------| -------------- | -------------- -| --------------------------------------- | ----------- | ------------
55            | sa              |  NevzatW11 | BYM_TCR-NEVZATW11-15780-1 |  sleeping  | 6

Not: program_name deki bu veri Params.Add('Applicationname='  parametresi ile oluşturuluyor.

bu sorguyla mssql de programı çalıştırmış olan kullanıcıları alabiliyorum, bu yapıyı firebird üzerinde nasıl oluşturabilirim?
Cevapla
#2
Hangi Firebird sürümünü kullandığınızı belirtmemişsiniz. Ayrıca tüm kullanıcılar için aynı SYSDBA kullanıcısı ile bağlanıp bağlanmadığınız da önemli. Her kullanıcının kendi user'ı var ise daha anlamlı olacaktır. Aşağıdaki kod sanırım işinizi görecektir :

SELECT 
   MON$ATTACHMENT_ID AS OTURUM_ID,
   MON$USER AS KULLANICI_ADI,
   MON$REMOTE_ADDRESS AS Client_IP_ADRESI,
   MON$REMOTE_PROCESS AS Client_Uygulama_ADI,
   MON$TIMESTAMP AS BAGLANTI_BASLANGICI,
   CASE MON$STATE 
       WHEN 0 THEN 'Beklemede' 
       WHEN 1 THEN 'Aktif' 
   END AS State
FROM MON$ATTACHMENTS
WHERE MON$ATTACHMENT_ID <> CURRENT_CONNECTION;
Firebird Ekipler Amiri. Dmitry Kouzmenko ve Dmitry Yemanov ile çalışmış , Eski IBSurgeon personeli, Kıdemli Firebird Kurtarma Uzmanı, Firebird Foundation bağışçısı...
Cevapla
#3
(26-09-2026, Saat: 09:40)rmzgenius Adlı Kullanıcıdan Alıntı: Hangi Firebird sürümünü kullandığınızı belirtmemişsiniz. Ayrıca tüm kullanıcılar için aynı SYSDBA kullanıcısı ile bağlanıp bağlanmadığınız da önemli. Her kullanıcının kendi user'ı var ise daha anlamlı olacaktır. Aşağıdaki kod sanırım işinizi görecektir :

SELECT 
   MON$ATTACHMENT_ID AS OTURUM_ID,
   MON$USER AS KULLANICI_ADI,
   MON$REMOTE_ADDRESS AS Client_IP_ADRESI,
   MON$REMOTE_PROCESS AS Client_Uygulama_ADI,
   MON$TIMESTAMP AS BAGLANTI_BASLANGICI,
   CASE MON$STATE 
       WHEN 0 THEN 'Beklemede' 
       WHEN 1 THEN 'Aktif' 
   END AS State
FROM MON$ATTACHMENTS
WHERE MON$ATTACHMENT_ID <> CURRENT_CONNECTION;

Firebird 5 versiyonu kurulu, bu veritabanı ile çalışmaya yeni başladım, SYSDBA dışında her kullanıcı için kendi user'ını oluşturarak kullanmak mantıklı olacak , verdiğiniz kod ile ip adresi hariç diğer verilere ulaştım, çok teşerkkür ederim...
Cevapla
#4
Tongue 
Hello @nevzatc

to Firebird 5 (last edition...), and before edition in some case, you can to a query in "System Tables", like: Attachments and Statements

a) you need access some system tables! MON$ATTACHMENTS and MON$STATEMENTS

SELECT
   A.MON$ATTACHMENT_ID AS ATTACHMENT_ID,
   A.MON$USER AS YOUR_USER_NAMES,
   A.MON$REMOTE_ADDRESS AS YOUR_IP_CLIENTS,
   A.MON$REMOTE_PID AS YOUR_PID_CLIENTS,
   A.MON$REMOTE_PROCESS AS YOUR_PROCESS_CLIENTS,
   S.MON$SQL_TEXT AS YOUR_SQL_IN_EXECUTIONS,
   S.MON$TIMESTAMP AS YOUR_STARTED_EXECUTIONS
    // ETC... ETC... ETC...
FROM MON$ATTACHMENTS A
LEFT JOIN MON$STATEMENTS S ON A.MON$ATTACHMENT_ID = S.MON$ATTACHMENT_ID
WHERE A.MON$ATTACHMENT_ID <> CURRENT_CONNECTION;


Now, regarding the creation of "users" for each individual in your system:

a) You could create a "role" in your Firebird database. This way, you would simply assign each user to this role, and everything would be automatically configured for them!

b) Each role you create could be linked to a specific set of rules, depending on the permissions you want to grant or restrict for that role or user within the database. For example: a "ReadOnly_For_Printing" role would have read privileges but no write access, etc.

c) A user could be assigned to more than one role, creating a highly flexible environment for adding or removing users from specific roles.

Example:
CREATE ROLE ReadOnly_For_Printing;
CREATE ROLE Select_Write_Delete_Execute_Role;

GRANT SELECT ON Table_Number_1 TO ROLE ReadOnly_For_Printing;
GRANT SELECT, DELETE, EXECUTE ON Table_Number_2 TO ROLE Select_Write_Delete_Execute_Role;
GRANT ReadOnly_For_Printing TO User_Name_John;
GRANT Select_Write_Delete_Execute_Role TO User_Name_John, User_Name_Mary;
...
REVOKE DELETE ON Table_Number_2 FROM ROLE Select_Write_Delete_Execute_Role; // table with no permissions = user no permissions
REVOKE ALL ON Table_Number_1 FROM ROLE ReadOnly_For_Printing;

Regarding the use of parameterized SQL:

a) prefer using "parameterized queries" to avoid "SQL Injection":

example:

select << your fields >>  from << your table >>
where   XField = :XField_Value

in Delphi code, some like this:
AQuery.Params.Clear;
AQuery.ParamByName('XField_Value').AsString {your type} := '123' {your value};  // define your params in FireDAC options in your FDQuery


One more tip:

Tongue 1) It is better to create a small, self-contained class to read your data from the "ini" file; this way, you avoid code duplication or cluttering your code with repetitive commands.

a) In this class, you would have all exceptions handled, values protected, and desired results obtained—along with error reporting for issues encountered during the "Ini" file reading process, etc.—all securely encapsulated, resulting in cleaner, more maintainable code.

b) Since this class would be widely used in the project and serves only one function across the entire system—delivering essential database information—you could turn it into a "singleton," given that there would be no need for multiple instances of the class throughout the project. This would centralize tasks and prevent other parts of the code from modifying data or receiving random or inconsistent information.

c) This tip applies to other scenarios where a small yet highly efficient class could be used to retrieve system information—keeping everything in one easily accessible place.

Since you need details about your local or network environment, running processes, and so on, a "singleton" class would be incredibly handy here!

TMy_System_Info = class ...
TMy_Database_Info = class ...
TMy_Read_INI_File = class ...
... 3 singletons for each specific use!!! functions/procedure/property ... encapsuling info with security


type
TMyClass_Read_INI = class
class function getPassWordDecripted; // readonly
property DB_FullPath: string read getDBFullPath; .....
end;

class function TMyClass.getDBPasswordDecripted:string;
begin
a) read INI file
b) decrypt the password if found
c) result := my_password_decrypted;
end;


...

FDDatabase.Param.Add( 'Password'= TMyClass.getDBPasswordDecripted);


For more tips and Code:  Angel
visit my channel in Youtube and Subscribe it :   http://www.youtube.com/emailx45
MSWindows, Android, RAD Studio 13 Florence ve kafamda bir fikir  Tongue  
WWW
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
Question Delphi formunu nasıl otomatik tam ekran yapabilirim ? erdemklt0 2 774 23-01-2026, Saat: 10:02
Son Yorum: csunguray
  Delphi İle Firebird 2.5x Uzaktan Yedekleme Aracı COMMANDX 1 668 25-10-2025, Saat: 22:19
Son Yorum: mcuyan
  TMS Web Core- REST İşlemlerini Nasıl Yapabilirim? kajmerantime 0 587 13-06-2025, Saat: 14:07
Son Yorum: kajmerantime
  Delphi 7 deki pencereleri nasıl sabitleyebilirim? mxpain 1 727 12-12-2024, Saat: 08:50
Son Yorum: 3ddark
  resimdeki hatanin satirini nasil bulabiliriz. sadikacar60 6 1.615 25-11-2024, Saat: 19:18
Son Yorum: sadikacar60



Konuyu Okuyanlar: 1 Ziyaretçi