Loading...
Searching...
No Matches
startupservice.sas
Go to the documentation of this file.
1/**
2 @file startupservice.sas
3 @brief List the libraries and tables the mp-editor user can access
4 @details If user is in a control group (&mpeadmins, configured in mpeinit.sas)
5 then they have access to all libraries / tables. Otherwise a join is made
6 to the &mpelib..mpe_security table.
7
8
9 <h4> SAS Macros </h4>
10 @li mf_getuser.sas
11 @li mpe_getgroups.sas
12 @li mp_abort.sas
13 @li mpeinit.sas
14
15 @version 9.2
16 @author 4GL Apps Ltd
17 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
18 and may not be re-distributed or re-sold without the express permission of
19 4GL Apps Ltd.
20**/
21
22%mpeinit()
23%mp_abort(iftrue= (&syscc ne 0)
24 ,mac=&_program..sas
25 ,msg=%str(Issue on startup in startupService)
26)
27
28%let userid=%mf_getuser();
29%put userid is &userid;
30%mpe_getgroups(user=&userid,outds=groups)
31%mp_abort(iftrue= (&syscc ne 0)
32 ,mac=&_program..sas
33 ,msg=%str(Issue with Groups syscc=&syscc for user &userid)
34)
35
36/* check if user is an admin */
37%let admin_check=0;
38proc sql noprint;
39select count(*) into: admin_check
40 from groups
41 where groupname="&mpeadmins";
42
43/* check if user is registered or not */
44%let isRegistered=0;
45select count(*) into: isregistered
46 from &mpelib..mpe_users
47 where user_id="&userid";
48
49/* get number of registered users */
50%let registerCount=0;
51select count(*) into: registercount
52 from &mpelib..mpe_users
53 where last_seen_dt>%sysfunc(today())-365;
54
55%mp_abort(iftrue= (&syscc ne 0)
56 ,mac=&_program..sas
57 ,msg=%str(Problem accessing &mpelib..mpe_users table)
58)
59
60%global dc_restrict_editrecord;
61data work.globvars;
62 dclib="&mpelib";
63 sas9lineage_enabled=1;
64 isadmin=&admin_check;
65 isregistered=&isregistered;
66 registercount=&registerCount;
67 dc_admin_group="&mpeadmins";
68 /* fetched from mpe_config in dc_getsettings */
69 licence_key="&dc_licence_key";
70 activation_key="&dc_activation_key";
71 dc_restrict_editrecord="&dc_restrict_editrecord";
72run;
73
74
75%macro mstp_mpeditorstartup();
76 data _null_;
77 putlog "entering &sysmacroname";
78 run;
79 proc sql noprint;
80 /* update last seen, if seen */
81 %if &isregistered>0 %then %do;
82 update &mpelib..mpe_users
83 set last_seen_dt=%sysfunc(today())
84 where user_id="&userid";
85 %end;
86 %mp_abort(iftrue= (&syscc ne 0)
87 ,mac=&_program..sas
88 ,msg=%str(Problem updating &mpelib..mpe_users table)
89 )
90
91 %local all_cnt;
92 select count(*) into: all_cnt
93 from &mpelib..mpe_security
94 where &dc_dttmtfmt. lt tx_to
95 and ACCESS_LEVEL in ('EDIT')
96 and libref='*ALL*'
97 and SAS_GROUP in (select groupname from groups);
98 %if &admin_check >0 or &all_cnt>0 %then %do;
99 create table sasDatasets as
100 select distinct libref, dsn
101 from &mpelib..mpe_tables
102 where &dc_dttmtfmt. lt tx_to
103 order by 1;
104 %end;
105 %else %do;
106 create table sasDatasets as
107 select distinct a.libref,a.dsn
108 from &mpelib..mpe_tables a
109 left join &mpelib..mpe_security b
110 on a.libref=b.libref
111 and a.dsn=b.dsn
112 where &dc_dttmtfmt. lt a.tx_to
113 and &dc_dttmtfmt. lt b.tx_to
114 and b.ACCESS_LEVEL in ('EDIT')
115 and b.SAS_GROUP in (select groupname from groups)
116 order by 1;
117 %end;
118%mend mstp_mpeditorstartup;
119%mstp_mpeditorstartup()
120
121create table saslibs as
122 select distinct libref
123 from &syslast;
124
125%mp_abort(iftrue= (&syscc ne 0)
126 ,mac=&_program..sas
127 ,msg=%str(issue with security validation)
128)
129
130proc sql;
131create table work.xlmaps as
132 select distinct a.XLMAP_ID
133 ,b.XLMAP_DESCRIPTION
134 ,coalescec(b.XLMAP_TARGETLIBDS,"&mpelib..MPE_XLMAP_DATA")
135 as XLMAP_TARGETLIBDS
136 from &mpelib..MPE_XLMAP_RULES a
137 left join &mpelib..MPE_XLMAP_INFO(where=(&dc_dttmtfmt. lt tx_to)) b
138 on a.XLMAP_ID=b.XLMAP_ID
139 where &dc_dttmtfmt. lt a.tx_to;
140
141/* we don't want the XLMAP target datasets to be directly editable */
142delete from sasdatasets
143 where cats(libref,'.',dsn) in (select XLMAP_TARGETLIBDS from xlmaps);
144
145%webout(OPEN)
146%webout(OBJ,sasDatasets)
147%webout(OBJ,saslibs)
148%webout(OBJ,globvars)
149%webout(ARR,xlmaps)
150%webout(CLOSE)
151
152%mpeterm()