Главная страница
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.027 c
3-1104229600
denis24
2004-12-28 13:26
2005.01.30
тип поля datetime


1-1105774192
Phantomouse
2005-01-15 10:29
2005.01.30
Как отследить закрытие программы


1-1105891816
KristinA
2005-01-16 19:10
2005.01.30
Delphi vikidivat tabli4ku "Bitmap image is not valid."


1-1105693275
Nad89
2005-01-14 12:01
2005.01.30
Тип данных типа string


14-1105345891
Kerk
2005-01-10 11:31
2005.01.30
Привет Подгорецкому от Эрики