.CM  SCRIPT , Version - 1.1 , last edited by barbara
.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 2000-2005 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.TT 1 $SQL$Project Distributed Database System$VIN86$
.tt 2 $$$
.TT 3 $$XUSER_Logon$1998-06-17$
***********************************************************
.nf
 
.nf
 
 .nf

    ========== licence begin  GPL
    Copyright (c) 2000-2005 SAP AG

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
.fo

 
.fo
 
 
.fo
.nf
.sp
MODULE  : XUSER_Logon
=========
.sp
Purpose : Logon to XUSER via sqlargs or input mask
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
&       ifdef WINDOWS
        FUNCTION
              sqlincallback (
                    VAR dummy       : tsp00_Int2;
                    rf              : tin_ls_releasemode;
                    context         : tin86_logon_pp;
                    callback_switch : tsp00_Int2;
                    VAR csr_pos     : tin_ls_position) : tsp00_DgcallbackResult;
&       endif
 
        PROCEDURE
              i86onscreen (
                    VAR ok : boolean);
 
        PROCEDURE
              i86logon (
                    wanted_username : tsp00_KnlIdentifier;
                    wanted_password : tsp00_CryptPw;
                    VAR given_uname : tsp00_KnlIdentifier;
                    VAR errmsg      : tin_screenline;
                    VAR connect_ok  : boolean);
 
        FUNCTION
              in8630 : tsp00_Int4;
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              global_variable : VIN01;
 
        VAR
              i01g : tin_global_in_vars;
&       ifndef WINDOWS
 
      ------------------------------ 
 
        FROM
              Logonscreen : VIN26;
 
        PROCEDURE
              i26upper_left_logon_screen (
                    VAR cl          : tin_comp_label);
&       endif
 
      ------------------------------ 
 
        FROM
              logical_screen : VIN50;
 
        PROCEDURE
              i50on (
                    VAR ok : boolean);
 
        PROCEDURE
              i50clear (
                    part : tin_ls_part);
 
        PROCEDURE
              i50put2field (
                    VAR field  : tsp00_C30;
                    length     : tin_natural;
                    field_pos  : tin_ls_position;
                    field_type : tin_ls_fieldtype);
 
        PROCEDURE
              i50put4field (
                    VAR field  : tsp00_C20;
                    length     : tin_natural;
                    field_pos  : tin_ls_position;
                    field_type : tin_ls_fieldtype);
 
        PROCEDURE
              i50getfield (
                    VAR vt_input    : tin_ls_input_field;
                    VAR field_found : boolean);
 
        PROCEDURE
              i50getwindow (
                    first_pos          : tin_ls_position;
                    window_len         : tin_natural;
                    window_width       : tin_natural;
                    VAR window_changed : boolean);
 
      ------------------------------ 
 
        FROM
              logical_screen_layout : VIN51;
 
        PROCEDURE
              i51layout (
                    functionmenu_length : tin_natural;
                    inputarea_length    : tin_natural;
                    msglines            : tin_natural);
 
      ------------------------------ 
 
        FROM
              logical_screen_modules : VIN56;
 
        PROCEDURE
              i56putlabels (
                    fct_cursorpos      : tin_ls_releasemode;
                    functionline_label : boolean);
 
        PROCEDURE
              i56errormessage ( screen_nr : tsp00_Int2;
                    VAR field : tsp00_C30;
                    length    : tin_natural );
&       ifdef WINDOWS
 
        PROCEDURE
              i56dlgremove (
                    boxid       : tsp00_Int2);
 
        PROCEDURE
              i56dlgbox (
                    box_id          : tsp00_Int2;
                    style           : tsp00_DlgBoxStyle;
                    screenpart      : tin_ls_part;
                    VAR trigger     : tin_ls_key_set;
                    immediate       : boolean;
                    callback_switch : tsp00_Int2;
                    context         : tsp00_BufAddr;
                    ok_button       : tin_ls_releasemode;
                    cancel_button   : tin_ls_releasemode);
&       endif
 
      ------------------------------ 
 
        FROM
              logical_screen_IO : VIN57 ;
 
        PROCEDURE
              i57ioscreen (
                    VAR csr_pos        : tin_ls_position;
                    VAR rf             : tin_ls_releasemode;
                    VAR screen_changed : boolean);
 
      ------------------------------ 
 
        FROM
              XUSER_GET : VIN87 ;
 
        PROCEDURE
              i87ngetusername  (
                    VAR buf      : tin_screenline;
                    len          : tin_natural;
                    VAR username : tsp00_KnlIdentifier);
 
        PROCEDURE
              i87pgetpassword (
                    VAR buf      : tin_screenline;
                    len          : tin_natural;
                    VAR password : tsp00_CryptPw);
 
      ------------------------------ 
 
        FROM
              Kernel_move_and_fill : VGG101;
 
        PROCEDURE
              SAPDB_PascalForcedFill (
                    size        : tsp00_Int4;
                    m           : tsp00_MoveObjPtr;
                    pos         : tsp00_Int4;
                    len         : tsp00_Int4;
                    fillchar    : char);
 
        PROCEDURE
              SAPDB_PascalForcedMove (
                    source_upb  : tsp00_Int4;
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
        PROCEDURE
              s10mv (
                    source_upb  : tsp00_Int4;       
                    destin_upb  : tsp00_Int4;
                    source      : tsp00_MoveObjPtr;    
                    source_pos  : tsp00_Int4;
                    destin      : tsp00_MoveObjPtr;    
                    destin_pos  : tsp00_Int4;
                    length      : tsp00_Int4);
 
      ------------------------------ 
 
        FROM
              RTE-Extension-30 : VSP30;
 
        FUNCTION
              s30gad1(
                    VAR b : tin86_logon_parms) : tsp00_BufAddr;
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              i50put2field;
 
              tsp00_MoveObj tsp00_C30
 
        PROCEDURE
              i50put4field;
 
              tsp00_MoveObj tsp00_C20
 
        PROCEDURE
              s30gad1;
 
              tsp00_MoveObj tin86_logon_parms
              tsp00_Addr tsp00_BufAddr
 
        PROCEDURE
              i56errormessage ;
 
              tin_screenline tsp00_C30
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  :
.sp
.cp 3
Created : 1992-03-16
.sp
.cp 3
.sp
.cp 3
Release :      Date : 1998-06-17
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
PROCEDURE
      logon (
            VAR username   : sql_user_name;
            VAR password   : name;
            VAR connect_ok : boolean);
.sp;.fo
Calls the logon_screen and compares user inputs with the parameters
'username' and 'password'.  The user is allowed 3 attempts.
Input parameters:
.br;.nf
username, password   (assigned via sqluser)
Output parameters:
connect_ok : true if user information matches;
             otherwise, false
.sp 2
PROCEDURE
      in85il_init_logon_screen;
.sp;.fo
Zeigt den logon-screen mit 2 Eingabefeldern f?ur username und password
am Bildschirm an.
.sp 2;.nf
PROCEDURE
      in85_transfer_input (
            VAR username   : sql_user_name;
            VAR password   : name;
            VAR get_ok     : boolean;
            VAR connect_ok : boolean;
            VAR ende       : boolean);
.sp;.fo
Liest die Benutzereingaben  und vergleicht sie mit username und password.
Eingabeparameter:
.br;.nf
username, password   (durch sqluser belegt)
Ausgabeparameter:
get_ok     : false falls releasekey clear oder unknown, sonst true
connect_ok : true falls Benutzerangaben ?ubereinstimmen, sonst false
ende       : false falls end_key (pf03, sk09), sonst true
.sp 2
PROCEDURE
      in86_read_username (
            VAR ein_buf    : ti_ls_input_field;
            VAR username   : sql_user_name;
            VAR connect_ok : boolean);
 
PROCEDURE
      in86_read_password (
            VAR ein_buf    : ti_ls_input_field;
            VAR password   : name;
            VAR connect_ok : boolean);
.sp;.fo
Vergleichen der Benutzereingaben mit
username bzw password.
Eingabeparameter:
.br;.nf
ein_buf : Eingabefeld des Bildschirms
username, password   (durch sqluser belegt)
Ausgabeparameter:
connect_ok : true falls ?Ubereinstimmung, sonst false
.sp 2
PROCEDURE
      in85_outscreen_userparms (
            VAR username : sql_user_name;
                  VAR password : name;
                  VAR locname  : sql_dbname);
.sp;.fo
Bildschirmausgabe von username, password (unsichtbar) und locname,
Einlesen der eventuell ge?anderten Werte und abspeichern in der
Datei 'XUSER SQLDB A1'.
Eingabeparameter:
.br;.nf
username, password , locationname
Ausgabeparameter:
keine
.sp 2;.oc _/1;Enhancements to MS-WINDOWS
.sp;This module has been changed to comply MS-Windows conventions;
Especially, the Callback function SQLINCALLBACK has been
implemented with input checks. For this purpose, the global
variable I86G has been invented, so that this variable contains
all parameters necessary to process user and password checking
properly.
.sp;For this reason, the structure of the logon proceeding has been
slightly changed.
.sp;Also, an exit message has been implemented after unsuccessful
logoff.
.CM *-END-* description ---------------------------------
.sp 3
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      logon_box    = 201;
      switch_logon = 18501;
 
TYPE
 
      tin86_logon_parms = RECORD
            username   : tsp00_KnlIdentifier;
            password   : tsp00_CryptPw;
            get_ok     : boolean;
            connect_ok : boolean;
            stop       : boolean;
            trial      : integer;
      END;
 
      tin86_logon_pp = ^tin86_logon_parms;
 
 
(*------------------------------*) 
 
FUNCTION
      in8630 : tsp00_Int4;
 
BEGIN
(* linkcheck function *)
in8630 := 214820525;
END;
 
&ifdef WINDOWS
(*------------------------------*) 
 
FUNCTION
      sqlincallback (
            VAR dummy       : tsp00_Int2;
            rf : tin_ls_releasemode;
            context         : tin86_logon_pp;
            callback_switch : tsp00_Int2;
            VAR csr_pos     : tin_ls_position) : tsp00_DgcallbackResult;
 
VAR
      screen_changed : boolean;
      errmsg         : tin_screenline;
 
BEGIN
dummy := dummy; (* for usecheck *)
IF  callback_switch = switch_logon
THEN
    BEGIN
    in86_transfer_input (context^, rf, errmsg);
    IF  NOT context^.connect_ok AND NOT context^.stop
    THEN
        BEGIN
        (* out error message *)
        WITH csr_pos DO
            BEGIN
            screen_nr := 1;
            screen_part := cin_ls_workarea;
            sline := 18;
            scol := 20;
            END;
        (*ENDWITH*) 
        i57ioscreen  (csr_pos, rf, screen_changed);
        WITH csr_pos DO
            BEGIN
            screen_nr := 1;
            screen_part := cin_ls_workarea;
            sline := 18;
            scol := 20;
            END;
        (*ENDWITH*) 
        END;
    (*ENDIF*) 
    IF  context^.connect_ok
    THEN
        sqlincallback := dg_ok
    ELSE
        IF  context^.stop
        THEN
            sqlincallback := dg_cancel
        ELSE
            BEGIN
            sqlincallback := dg_again;
            in85_set_keys;
            END;
        (*ENDIF*) 
    (*ENDIF*) 
    END
ELSE
    sqlincallback := dg_ok ;
(*ENDIF*) 
END;
 
&endif
(*------------------------------*) 
 
PROCEDURE
      i86onscreen (
            VAR ok : boolean);
 
CONST
      inputarea_length    = 0;
      functionmenu_length = 1;
      message_lines       = 1;
 
BEGIN
i50on (ok);
IF  ok
THEN
    i51layout  (functionmenu_length, inputarea_length, message_lines);
(*ENDIF*) 
END; (* in86onscreen *)
 
(*------------------------------*) 
 
PROCEDURE
      i86logon (
            wanted_username : tsp00_KnlIdentifier;
            wanted_password : tsp00_CryptPw;
            VAR given_uname : tsp00_KnlIdentifier;
            VAR errmsg      : tin_screenline;
            VAR connect_ok  : boolean);
 
VAR
      rf             : tin_ls_releasemode;
      csr_pos        : tin_ls_position;
      screen_changed : boolean;
      i86g           : tin86_logon_parms;
 
BEGIN
i86g.username := wanted_username;
i86g.password := wanted_password;
i86g.connect_ok := connect_ok;
i50clear (cin_ls_basic_window);
in86il_init_logon_screen (given_uname, i86g);
WITH i01g^.vt.opt DO
    BEGIN
    wait_for_input := true;
    usage_mode      := vt_form;
    return_on_last  := true;
    return_on_first := false;
    returnkeys      :=  [  ] ;
    reject_keys     :=  [  ] ;
    bell := false;
    END;
(*ENDWITH*) 
WITH csr_pos DO
    BEGIN
    screen_nr := 1;
    screen_part := cin_ls_workarea;
    sline := 18;
    scol := 20;
    END;
(*ENDWITH*) 
i86g.stop := false;
i86g.connect_ok := false;
i86g.trial := 1;
WHILE NOT i86g.connect_ok AND NOT i86g.stop DO
    BEGIN
    i57ioscreen  (csr_pos, rf, screen_changed);
    in86_transfer_input (i86g, rf, errmsg);
    END;
(*ENDWHILE*) 
&ifdef WINDOWS
i56dlgremove ( logon_box );
&endif
connect_ok := i86g.connect_ok ;
END; (* i86logon *)
 
(*------------------------------*) 
 
PROCEDURE
      in86il_init_logon_screen (
            VAR given_uname : tsp00_KnlIdentifier;
            VAR i86g        : tin86_logon_parms);
 
CONST
      start_col =  7;
 
VAR
      i         : integer;
      fieldname : ARRAY [ 1..2 ] OF tsp00_C30;
      tuser     : tsp00_C20;
      fieldpos  : tin_ls_position;
      fieldtype : tin_ls_fieldtype;
      cl        : tin_comp_label;
&     ifdef WINDOWS
      trigger : tin_ls_key_set;
&     endif
 
BEGIN
WITH fieldpos DO
    BEGIN
    screen_nr := 1;
    screen_part := cin_ls_workarea;
    sline := 1;
    scol := start_col;
    END;
(*ENDWITH*) 
WITH fieldtype DO
    BEGIN
    field_att := cin_ls_enhanced;
    fieldmode :=  [  ] ;
    END;
(*ENDWITH*) 
in85_set_keys;
&ifdef WINDOWS
trigger := [ ] ;
i56dlgbox ( logon_box, dg_modal, cin_ls_workarea, trigger, true,
      switch_logon, s30gad1( i86g ), f_enter, f_exit );
&else
cl := '    U  S  E  R      ';
i26upper_left_logon_screen  (cl);
&endif
fieldname   [1]  := 'Username ==>                  ';
fieldname   [2]  := 'Password ==>                  ';
FOR i := 1 TO sizeof (tsp00_KnlIdentifier) DO
    tuser [i] := given_uname [i];
(*ENDFOR*) 
tuser [sizeof (tsp00_KnlIdentifier) + 1] := bsp_c1;
tuser [sizeof (tsp00_KnlIdentifier) + 2] := bsp_c1;
fieldpos.sline := 18;
fieldpos.scol := start_col;
i50put2field (fieldname [1] , 12, fieldpos, fieldtype);
(* *)
fieldpos.scol := start_col + 13;
fieldtype.field_att := cin_ls_enhanced;
fieldtype.fieldmode :=  [ ls_input] ;
i50put4field  (tuser, mxsp_c20, fieldpos, fieldtype);
(* *)
fieldpos.scol := start_col + 35;
fieldtype.field_att := cin_ls_enhanced;
fieldtype.fieldmode :=  [  ] ;
i50put2field  (fieldname   [2] , 12, fieldpos, fieldtype);
(* *)
in86blank_password;
END; (* in86il_init_logon_screen *)
 
(*------------------------------*) 
 
PROCEDURE
      in86blank_password;
 
CONST
      start_col =  7;
 
VAR
      tpass     : tsp00_C20;
      fieldpos  : tin_ls_position;
      fieldtype : tin_ls_fieldtype;
 
BEGIN
WITH fieldpos DO
    BEGIN
    screen_nr := 1;
    screen_part := cin_ls_workarea;
    sline := 18;
    scol := start_col + 48;
    END;
(*ENDWITH*) 
WITH fieldtype DO
    BEGIN
&   ifdef WINDOWS
    field_att := cin_ls_normal;
    (* Control already defined as PASSWORD *)
&   else
    field_att := cin_ls_invisible;
&   endif
    fieldmode :=  [ ls_input ] ;
    END;
(*ENDWITH*) 
tpass := bsp_c20;
i50put4field  (tpass, mxsp_c20, fieldpos, fieldtype);
END; (* in86blank_password *)
 
(*------------------------------*) 
 
PROCEDURE
      in85_set_keys;
 
CONST
      blank_sk_label = '        ';
 
VAR
      f : f1 .. f_down;
 
BEGIN
WITH i01g^.key_type DO
    BEGIN
    FOR f := f1 TO f_down DO
        key_labels [  f  ] := blank_sk_label;
    (*ENDFOR*) 
    key_labels [  f9  ] := 'END     ';
    activated := [ f9, f_enter, f_end, f_exit] ;
    i50clear (cin_ls_functionmenu);
    i56putlabels (f_clear, false);
    END;
(*ENDWITH*) 
END; (* in85_set_keys *)
 
(*------------------------------*) 
 
PROCEDURE
      in86_transfer_input (
            VAR i86g   : tin86_logon_parms;
            rf         : tin_ls_releasemode;
            VAR errmsg : tin_screenline);
 
VAR
      blank_user : tsp00_KnlIdentifier;
      user_error : tsp00_C30;
 
BEGIN
i86g.get_ok := false;
blank_user := bsp_c64;
user_error := 'USERNAME/PASSWORD ILLEGAL     ';
IF  rf IN  [ f9, f_exit, f_end ]
THEN
    i86g.stop := true
ELSE
    IF  rf = f_clear
    THEN
        in86il_init_logon_screen (blank_user, i86g)
    ELSE
        BEGIN
        i86g.get_ok := true;
        in86read_user_password (i86g);
        END;
    (*ENDIF*) 
(*ENDIF*) 
IF  (i86g.trial = 3) AND NOT i86g.connect_ok
THEN
    i86g.stop := true
ELSE
    i86g.trial := i86g.trial + 1;
(*ENDIF*) 
IF  i86g.get_ok AND NOT (i86g.connect_ok OR i86g.stop)
THEN
    BEGIN
    in86blank_password;
    i56errormessage ( 1, user_error, 30 );
    END;
(*ENDIF*) 
IF  i86g.connect_ok OR i86g.stop
THEN
    SAPDB_PascalForcedFill (mxin_screenline, @errmsg, 1, mxin_screenline, bsp_c1 )
ELSE
    s10mv (mxsp_c30,mxin_screenline,
          @user_error,1,
          @errmsg,1,mxsp_c30);
(*ENDIF*) 
END; (* in86_transfer_input *)
 
(*------------------------------*) 
 
PROCEDURE
      in86read_user_password (
            VAR i86g       : tin86_logon_parms);
 
VAR
      first_pos      : tin_ls_position;
      window_changed : boolean;
 
BEGIN
WITH first_pos  DO
    BEGIN
    screen_nr := 1;
    screen_part := cin_ls_workarea;
    sline := 1;
    scol := 1;
    END;
(*ENDWITH*) 
i50getwindow ( first_pos, 999, 999, window_changed);
in86_read_username  (i86g.username, i86g.connect_ok);
in86_read_password  (i86g.password, i86g.connect_ok);
END; (* in86read_user_password *)
 
(*------------------------------*) 
 
PROCEDURE
      in86_read_username (
            VAR username     : tsp00_KnlIdentifier;
            VAR connect_ok   : boolean);
 
VAR
      inp_buf     : tin_ls_input_field;
      field_found : boolean;
      local_name  : tsp00_KnlIdentifier;
 
BEGIN
i50getfield  (inp_buf, field_found);
IF  NOT field_found
THEN
    connect_ok := false
ELSE
    WITH inp_buf DO
        BEGIN
        i87ngetusername (buf, len, local_name);
        connect_ok :=  (username = local_name);
        END;
    (*ENDWITH*) 
(*ENDIF*) 
END; (* in86_read_username *)
 
(*------------------------------*) 
 
PROCEDURE
      in86_read_password (
            VAR password   : tsp00_CryptPw;
            VAR connect_ok : boolean);
 
VAR
      i           : integer;
      inp_buf     : tin_ls_input_field;
      field_found : boolean;
      local_pw    : tsp00_CryptPw;
      equal       : boolean;
 
BEGIN
IF  connect_ok
THEN
    BEGIN
    i50getfield  (inp_buf, field_found);
    IF  NOT field_found
    THEN
        connect_ok := false
    ELSE
        WITH inp_buf DO
            BEGIN
            i87pgetpassword (buf, len, local_pw);
            equal := true;
            FOR i := 1 TO CRYPTPW_MXSP00 DO
                IF  local_pw   [i]  <> password   [i]
                THEN
                    equal := false;
                (*ENDIF*) 
            (*ENDFOR*) 
            connect_ok := equal;
            END;
        (*ENDWITH*) 
    (*ENDIF*) 
    END;
(*ENDIF*) 
END; (* in86_read_password *)
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
.PA 
