celeb sex tapes
free celebrity sex videos
free celeb sex tapes

Delphi-Help

  • Increase font size
  • Default font size
  • Decrease font size
Главная

Назначение прав пользователей на таблицу

Оцените материал
(0 голосов)


Назначение прав пользователей на таблицу

{ **** UBPFD *********** by delphibase.endimus.com ****
>> Назначение прав пользователей на таблицу
 
Какое может быть описание? И так все понятно. Кто делает эти формы?
 
Зависимости: uses IBQuery,IBDataBase,SysUtils
Автор:       Dracula, 
 

Этот e-mail адрес защищен от спам-ботов, для его просмотра у Вас должен быть включен Javascript
 
, Krivoy Rog
Copyright:   Dracula
Дата:        28 января 2003 г.
***************************************************** }
 
unit IBRights;
interface
 
uses IBQuery, IBDataBase, SysUtils;
 
type
  TIBUserRights = record
    sel: Boolean;
    ins: Boolean;
    upd: Boolean;
    del: Boolean;
    exe: Boolean;
  end;
 
function GetUserRights(UserName, Relation: string; IBDb: TIBDataBase):
  TIBUserRights;
var
  Rights: TIBUserRights;
 
implementation
 
function GetUserRights(UserName, Relation: string; IBDb: TIBDataBase):
  TIBUserRights;
var
  Qr: TIBQuery;
  Tr: TIBTransaction;
begin
  if Assigned(IBDb) then
  begin
    Tr := TIBTransaction.Create(nil);
    try
      Tr.DefaultDatabase := IBDb;
      Qr := TIBQuery.Create(nil);
      Qr.Database := IBDb;
      Tr.StartTransaction;
      Qr.Close;
      Qr.Sql.Clear;
      Qr.Sql.Add('select RDB$USER,RDB$PRIVILEGE,RDB$RELATION_NAME ' +
        'from RDB$USER_PRIVILEGES ' +
        'where upper(RDB$USER)=:AUser ' +
        'and upper(RDB$RELATION_NAME)=:ARelation');
      Qr.Prepare;
      Qr.Params.ParamValues['AUser'] := AnsiUpperCase(UserName);
      Qr.Params.ParamValues['ARelation'] := AnsiUpperCase(Relation);
      Qr.Open;
      while not Qr.eof do
      begin
        if Copy(Trim(Qr.FieldByName('RDB$PRIVILEGE').AsString), 1, 1) = 'S' then
          Rights.sel := true
        else
          Rights.sel := false;
        if Copy(Trim(Qr.FieldByName('RDB$PRIVILEGE').AsString), 1, 1) = 'I' then
          Rights.ins := true
        else
          Rights.ins := false;
        if Copy(Trim(Qr.FieldByName('RDB$PRIVILEGE').AsString), 1, 1) = 'U' then
          Rights.upd := true
        else
          Rights.upd := false;
        if Copy(Trim(Qr.FieldByName('RDB$PRIVILEGE').AsString), 1, 1) = 'D' then
          Rights.del := true
        else
          Rights.del := false;
        if Copy(Trim(Qr.FieldByName('RDB$PRIVILEGE').AsString), 1, 1) = 'X' then
          Rights.exe := true
        else
          Rights.exe := false;
        if Copy(Trim(Qr.FieldByName('RDB$PRIVILEGE').AsString), 1, 1) = 'R' then
          //Rights.ref:=true else Rights.ref:=false;
        begin
          Rights.sel := true;
          Rights.ins := true;
          Rights.upd := true;
          Rights.del := true;
          Rights.exe := true;
        end;
        Qr.Next;
      end;
      Qr.Close;
      Tr.Commit;
      Qr.Free;
    finally
      Tr.Free;
    end;
  end;
  Result := Rights;
end;
 
end.
Пример использования: 
uses....., IBRights;
......
var
  rights: TIBUserRights;
 
implementation
.....
begin
  ...
  rights := GetUserRights(DllLogin, NameTable, IBDataBase);
  .....
end;
Прочитано 5313 раз

Авторизация



Счетчики