zoukankan      html  css  js  c++  java
  • TDSAuthenticationManager的用法

    TDSAuthenticationManager的用法

    xe开始有了TDSAuthenticationManager,这个主要用来做用户认证,用法也很简单

    服务器端


    1.TDSAuthenticationManager有两个主要的事件

    在这个事件里面,看看检测连上来的用户名,密码是否合法,valid如果置为false,这就为非法连接了,DSServer会立刻抛出异常后close连接。

    procedure TServerContainer1.DSAuthenticationManager1UserAuthenticate(
    Sender: TObject; const Protocol, Context, User, Password: string;
    var valid: Boolean; UserRoles: TStrings);
    begin
    { TODO : Validate the client user and password.
    If role-based authorization is needed, add role names to the UserRoles parameter }
    if (User=authParams.user) and (Password=authParams.password) then
    valid := True
    else valid := False;
    end;

    在这个事件里面,判断已经连接上来的用户,对ServerMethod的调用是否合法,注视里也写了,默认是如何检测是否合法的。
    procedure TServerContainer1.DSAuthenticationManager1UserAuthorize(   Sender: TObject; EventObject: TDSAuthorizeEventObject;   var valid: Boolean);
    begin 
    { TODO : Authorize a user to execute a method.     Use values from EventObject such as UserName, UserRoles, AuthorizedRoles and
    DeniedRoles.     Use DSAuthenticationManager1.Roles to define Authorized and Denied roles     for particular server methods. } 
    //valid := True;
    end;

    客户端:

    with SQLConnection1 do
    begin
    Connected := False;
    ConnectionName := 'DataSnapCONNECTION';
    Params.Clear;
    DriverName := 'DataSnap';
    Params.Add('DriverName=DataSnap');
    Params.Add('CommunicationProtocol=tcp/ip');
    Params.Add('HostName=' + appInfo.appSvrIp);
    Params.Add('port=' + IntToStr(appInfo.appSvrPort));
    Params.Add('DSAuthenticationUser=' + appInfo.appSvrUser);
    Params.Add('DSAuthenticationPassword=' + appInfo.appSvrPassword);
    end;
    end;

  • 相关阅读:
    SSM后台管理开发日志(三)
    文件权限
    adb详细教学
    adb基础命令001
    SQL训练题库002(建议copy到sqlserver里实战练习,多做一下)
    SQL增删改查,列的更改,更改列名表名,运算符连接符,注释
    SQL增加约束
    SQL 建表、删表和数据,增删约束
    The firstday i join in cnblogs..."Hello everyone"...
    C#日期时间格式化
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2365829.html
Copyright © 2011-2022 走看看