Главная страница
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.028 c
3-1104177126
NEEDHELP
2004-12-27 22:52
2005.01.30
Oshibka pri vvode dati =(


1-1106222018
Degobar
2005-01-20 14:53
2005.01.30
Можно ли скопировать облать из wmf файла в bitmap


3-1103553098
Lamka
2004-12-20 17:31
2005.01.30
Фильтрация в DBGrid


1-1105679758
Nik8.
2005-01-14 08:15
2005.01.30
Почему функция неверно считает?


3-1104155962
Артемиус
2004-12-27 16:59
2005.01.30
Как определить количество и имена таблиц в базе?