90 lines
2.5 KiB
SAS
Executable File
90 lines
2.5 KiB
SAS
Executable File
/**
|
|
@file
|
|
@brief Checks the level of access a user has to the MP Editor
|
|
@details In order for a user to be able to EDIT or APPROVE a table they must
|
|
be in a metadata group that has been granted access to that table in the
|
|
&mpelib..mpe_security table. Alternatively, they may be in the
|
|
&mpeadmins group (has overall access).
|
|
|
|
<h4> SAS Macros </h4>
|
|
@li mp_abort.sas
|
|
@li mf_verifymacvars.sas
|
|
@li mpe_getgroups.sas
|
|
@li mp_dropmembers.sas
|
|
|
|
@param [in] access_level= access_level (per &mpelib..mp_editor_security) reqd
|
|
|
|
@returns outds A table containing all the groups that user is a member of,
|
|
which are granted the access_level requested.
|
|
|
|
@version 9.2
|
|
@author 4GL Apps Ltd
|
|
@copyright 4GL Apps Ltd. This code may only be used within Data Controller
|
|
and may not be re-distributed or re-sold without the express permission of
|
|
4GL Apps Ltd.
|
|
**/
|
|
|
|
%macro mpe_accesscheck(
|
|
base_table /* base table to check for */
|
|
,outds=med_accesscheck /* WORK table to contain access details */
|
|
,user= /* metadata user to check for */
|
|
,access_level=APPROVE
|
|
);
|
|
|
|
%if &user= %then %let user=%mf_getuser();
|
|
|
|
%if %index(&outds,.) %then %do;
|
|
%local lib ds;
|
|
%let lib=%scan(&outds,1,.);
|
|
%let ds=%scan(&outds,2,.);
|
|
%if %upcase(&lib) ne WORK %then %do;
|
|
%mp_abort(msg=outds should be a WORK table
|
|
,mac=mpe_accesscheck);
|
|
%end;
|
|
%end;
|
|
%else %let ds=&outds;
|
|
|
|
%mp_abort(
|
|
iftrue=(%mf_verifymacvars(base_table user access_level)=0)
|
|
,mac=bitemporal_dataloader
|
|
,msg=%str(Missing base_table/user access_level)
|
|
)
|
|
|
|
/* ensure any existing table is dropped */
|
|
%mp_dropmembers(&ds)
|
|
|
|
/* create a new table for temp use */
|
|
data; run;
|
|
%local tempds; %let tempds=&syslast;
|
|
|
|
/* overwrite with the list of groups */
|
|
%mpe_getgroups(user=&user,outds=&tempds);
|
|
|
|
%if &_debug ge 131 %then %do;
|
|
data _null_;
|
|
set &tempds;
|
|
putlog (_all_)(=);
|
|
run;
|
|
%end;
|
|
|
|
proc sql;
|
|
create table &outds as
|
|
select * from &tempds
|
|
where groupname="&mpeadmins"
|
|
or groupname in
|
|
(select sas_group from &mpelib..mpe_security
|
|
where &dc_dttmtfmt. lt tx_to
|
|
and access_level="&access_level"
|
|
& (
|
|
(libref="%scan(&base_table,1,.)" and dsn="%scan(&base_table,2,.)")
|
|
or (libref="%scan(&base_table,1,.)" and dsn="*ALL*")
|
|
or (libref="*ALL*")
|
|
)
|
|
);
|
|
|
|
%put base_table=&base_table;
|
|
%put libref=%scan(&base_table,1,.);
|
|
%put dsn=%scan(&base_table,2,.);
|
|
%put access_level=&access_level;
|
|
%mend mpe_accesscheck;
|