Using the Troleauth class, a kind of gaze-like code for authorization, is also the simplest and most convenient way to implement the following:
UnitServerMethodsUnit1;Interfaceusessystem.sysutils, System.classes, System.json, Datasnap.dsserver, Datasnap.dsauth, Datasnap.dsproviderdatamoduleadapter;typeTServerMethods1=class(Tdsservermodule)Private {Private Declarations} Public {Public Declarations}[Troleauth ('AdminGroup','Guestgroup')] functionEchostring (Value:string):string; [Troleauth ('Guestgroup','AdminGroup')] functionReverseString (Value:string):string; End;Implementation{$R *.DFM}usessystem.strutils;functionTservermethods1.echostring (Value:string):string;beginResult:=Value;End;functionTservermethods1.reversestring (Value:string):string;beginResult:=System.StrUtils.ReverseString (Value);End;End.
Compilation environment: Delphi XE7
Join Datasnap Advanced Exchange Group 439992010 to download this demo
Using the Troleauth class to authorize interface to the DATASNAP server