Subject Re: [firebird-support] Re: Running UDF from rFunc
Author Woody
From: "Codebue Fabio - P-Soft" <f.codebue@...>
> Adam,
> I'm using Delphi 7, ionly for this project so big that in this
> moment I don't wanna migrate to bds.
> In d7 IBAdmin component don't work and I don't know how to use service API
> Could I have a list of them and a sample to use them in delphi?

This should get you started. Haven't tried it on FB2 but it works fine in
earlier versions. I believe the structures and functions are contained in
the IBase32.pas file of IBX.

NOTE: This was taken from a working program, however, I edited it here to
remove non-relevant information specific only to the program. I can't
guarantee this will run without some editing and testing. Also, I don't use
full name information but you can change that if you need to by prompting
for more information and passing it to the function.

HTH
Woody (TMW)

function AddAUser(UserName, PassWd: string): boolean;
var
UserInfo: PUserInfo;
DBAInfo: TDBAInfo;
ServerInfo: PServerInfo;

begin
result := false;
UserInfo := AllocMem(sizeof(TUserInfo));
UserInfo^.FirstName := UserName;
UserInfo^.MiddleName := '';
UserInfo^.LastName := '';

ServerInfo := AllocMem(sizeof(TServerInfo));
ServerInfo^.Name := 'YourFBServerName';
ServerInfo^.Protocol := sec_protocol_tcpip;

// Always need to have a DBA user name and password (usually SYSDBA)...
DBAInfo.Name := MasterUser;
DBAInfo.Password := MasterPassword;

try
try
result := (AddUser(ServerInfo, DBAInfo, UserName, PassWd, UserInfo) =
0);
except
// exception handling here for whatever you need in case of failure
end;
finally
if Assigned(UserInfo) then
FreeMem(UserInfo);
if Assigned(ServerInfo) then
FreeMem(ServerInfo);
end;
end;