![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
isc_add_user [D6, IB6.x]
Tomkat © (2004-12-25 15:03:00)Hi,мастера ! поскажите, как с помощью описанной в сабже фунуции доюавть пользователя серверу ?
Zacho (2004-12-25 15:25:00) [1]Естественно, вызвать её. Вот кусок из моего древнего компонента, вроде бы работал :)
TSUsers = class(TComponent)
private
FDatabase: TpFIBDatabase;
...
STATUS: ISC_STATUS;
SEC: TUserSecData;
Server: array[0..255] of char; // Путь до базы
User: array[0..50] of char; // Пользователь Админ
UserPas: array[0..50] of char; //
...
procedure SetSecStructure;
procedure ErrorMessage(Code: Integer);
public
...
procedure AddUser(UserName,password:string);
...
published
property Database: TpFIBDatabase read FDatabase write SeTpFIBDatabase;
end;
...
procedure TSUsers.SetSecStructure();
var ServerTmp: String;
begin
ServerTmp := FDatabase.DBName;
StrPCopy(User, FDatabase.DBParams.Values['USER_NAME']);
StrPCopy(UserPas, FDatabase.DBParams.Values['PASSWORD']);
if Pos(':', ServerTmp) > 0 then begin
Delete( ServerTmp, Pos(':', ServerTmp), 1);
if Pos(':', ServerTmp) > 0 then begin
SEC.protocol := sec_protocol_tcpip; (**Int protocol to use for connection **)
ServerTmp := Copy(ServerTmp,1,Pos(':', FDatabase.DBName)-1);
end else begin
SEC.protocol := sec_protocol_local; (**Int protocol to use for connection **)
ServerTmp := '';
end;
end;
StrPCopy(Server, ServerTmp);
SEC.sec_flags := sec_server_spec (**Short which fields are specified **)
or sec_password_spec
or sec_dba_user_name_spec
or sec_dba_password_spec;
//or sec_first_name_spec;
//or sec_last_name_spec;
SEC.uid := 0; (**Int the user's id **)
SEC.gid := 0; (**int the user's group id **)
SEC.server := Server; (**PChar server to administer **)
SEC.group_name := nil; (**PChar the group name **)
SEC.first_name := nil; (**PChar the user's first name **)
SEC.middle_name := nil; (**PChar the user's middle name **)
SEC.last_name := nil; (**PChar the user's last name **)
SEC.dba_user_name := User; (**PChar the dba user name **)
SEC.dba_password := UserPas; (**PChar the dba password **)
end;
...
procedure TSUsers.AddUser(UserName,password:string);
var ErrorCode: ISC_STATUS;
NewUser: array[0..50] of char; // Пользователь Админ
NewUserPas: array[0..50] of char; //
begin
SetSecStructure;
StrPCopy(NewUserPas, password); (**PChar the user's password **)
SEC.password := NewUserPas;
StrPCopy(NewUser, UserName); (**PChar the user's name **)
SEC.user_name := NewUser;
ErrorCode := isc_add_user(@STATUS , @SEC);
if ErrorCode > 0 then
ErrorMessage(ErrorCode)
end;