Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.01.30;
Скачать: CL | DM;

Вниз

isc_add_user   Найти похожие ветки 

 
Tomkat   (2004-12-25 15:03) [0]

Hi,мастера ! поскажите, как с помощью описанной в сабже фунуции доюавть пользователя серверу ?


 
Zacho ©   (2004-12-25 15:25) [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;



Страницы: 1 вся ветка

Текущий архив: 2005.01.30;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.024 c
10-1081908882
Tollya
2004-04-14 06:14
2005.01.30
Как сохранить в Exel


14-1105255050
Yegorchic
2005-01-09 10:17
2005.01.30
Ну когда обновят www.DelphiGFX.mastak.ru?


4-1102766199
Salikcool
2004-12-11 14:56
2005.01.30
Enabled


4-1102595459
serg128
2004-12-09 15:30
2005.01.30
Как на WinAPI переименовать файл?


9-1098387095
Sphinx
2004-10-21 23:31
2005.01.30
Переключить зрение в игре