Interbase中如何通过SQL语句实现用户管理(200分)

  • 主题发起人 主题发起人 wulianmin
  • 开始时间 开始时间
W

wulianmin

Unregistered / Unconfirmed
GUEST, unregistred user!
如:增加用户、修改口令等
 
在www.inprise.com的InterBase的部分有一分 SQL ROLE 的pdf文件,地址忘记了,自己出找一下。
 
好象只提供API,说错了不要笑!
isc_add_user() Adds a user to the password database
isc_delete_user() Deletes a user from the password database
isc_modify_user() Modifies user information in the password database
用法看一下:source/vcl/ibheader.pas
 
补充:
Victortim说的文档我已看过,在interbase中并无象
sql server中sp_add_login之类的SQL语句,该文档中
添加用户就是用API的,摘录如下:

File: Adduser.dpr
program Adduser;
uses
ibase in 'ibase.pas',
ib_externals in 'ib_externals.pas';
var
userData: TUserSecData;
userDataPtr: PUserSecData;
status: array[0..19] of ISC_STATUS;
isc_status: PISC_STATUS;
begin
{ setup isc_status pointer }
isc_status := @status;
{ setup user data pointer to point to user data structure }
userDataPtr := @userData;
{ setup user data structure }
userData.user_name := 'BJONES';
userData.password := 'bjones';
userData.protocol := sec_protocol_local;
userData.dba_user_name := 'SYSDBA';
userData.dba_password := 'masterkey'; /* Don't hardcode this */
userData.first_name := 'Bobby';
userData.last_name := 'Jones';
userData.sec_flags := sec_password_spec or sec_dba_user_name_spec or
sec_dba_password_spec
or sec_first_name_spec or sec_last_name_spec;
{ add user to security database }
isc_add_user(isc_status, userDataPtr);
end.

 
又补充:
Victortim说的文档在:
http://community.borland.com/article/0,1410,25921,00.html
 
eyes4:你好,非常感谢你的帮助,但是我找不到
ibase in 'ibase.pas',
ib_externals in 'ib_externals.pas';
两个文件,哪儿有? 我只找到ib.pas和ibexternals.pas
 
文档中的例子可能是用SDK编制的,我不是很清楚,不过你可以参考
ibintf.pas自已编一个,也不难,我写了一个,供参考:
unit main;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,ibexternals,ibheader;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
IBLibrary: THandle;
isc_add_user:Tisc_add_user;
implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
userData: TUserSecData;
userDataPtr: PUserSecData;
status: array[0..19] of ISC_STATUS;
isc_status: PISC_STATUS;
begin
{ setup isc_status pointer }
isc_status := @status;
{ setup user data pointer to point to user data structure }
userDataPtr := @userData;
{ setup user data structure }
userData.user_name := 'BJONES';
userData.password := 'bjones';
userData.protocol := sec_protocol_local;
userData.dba_user_name := 'SYSDBA';
userData.dba_password := 'masterkey'; // Don't hardcode this */
userData.first_name := 'Bobby';
userData.last_name := 'Jones';
userData.sec_flags := sec_password_spec or sec_dba_user_name_spec or
sec_dba_password_spec
or sec_first_name_spec or sec_last_name_spec;
{ add user to security database }
isc_add_user(isc_status, userDataPtr);
end;

procedure TForm1.FormCreate(Sender: TObject);
function GetProcAddr(ProcName: PChar): Pointer;
begin
Result := GetProcAddress(IBLibrary, ProcName);
if not Assigned(Result) then
RaiseLastWin32Error;
end;
begin
IBLibrary := LoadLibrary(PChar(IBASE_DLL));
isc_add_user := GetProcAddr('isc_add_user'); {do not localize}
end;

end.
注:IBASE_DLL在IBHEARD中有定义,为gds32.dll
 
在interbase用SQL语句来增加用户、修改口令是不太现实的,
当然你可以对isc4.gdb直接操作,但Passwd一项让人头疼。
如果你用的是interbase6的话,InterBase Admin中的
IBSecurityService让你2分钟搞定你的问题,看一下帮助
太简单了!!
 
多人接受答案了。
 
后退
顶部