mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 23:50:06 +00:00
Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b72e404d52 | ||
|
|
e31cdeef42 | ||
|
|
8a4e32cc27 | ||
|
|
f285505b79 | ||
|
|
67f5c50300 | ||
|
|
ce39e4f779 | ||
|
|
9c80f5664c | ||
|
|
83466c001b | ||
|
|
ad315be503 | ||
|
|
c41ae2dcc8 | ||
| d9f8e92fac | |||
|
|
d42ede15db | ||
|
|
08ea9f7c00 | ||
|
|
c327e1fc0d | ||
|
|
02fddcf9a1 | ||
|
|
4752bfbb05 | ||
|
|
767ddd7add | ||
|
|
54a24ced83 | ||
|
|
57ae2981f1 | ||
|
|
a3043ac685 | ||
|
|
2bdb90b0be | ||
|
|
2cd846d504 | ||
|
|
f593c7bec9 | ||
|
|
c8805db0b5 | ||
|
|
1eb6d8cec9 | ||
|
|
ed19ee03af | ||
|
|
a1c931b5e6 | ||
|
|
cb553a31ab | ||
|
|
557df272ff | ||
|
|
0cb3c96c15 | ||
|
|
1cb39d4d61 | ||
|
|
934b7d4f8a | ||
|
|
24c50cde56 | ||
|
|
055e8d2f13 | ||
|
|
abfe7fe339 | ||
|
|
16ed91f6a9 |
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
17
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
## Issue
|
||||||
|
|
||||||
|
Link any related issue(s) in this section.
|
||||||
|
|
||||||
|
## Intent
|
||||||
|
|
||||||
|
What this PR intends to achieve.
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
What code changes have been made to achieve the intent.
|
||||||
|
|
||||||
|
## Checks
|
||||||
|
|
||||||
|
- [ ] Code is formatted correctly (`sasjs lint`).
|
||||||
|
- [ ] Any new functionality has been unit tested.
|
||||||
|
- [ ] All unit tests are passing (`sasjs test`).
|
||||||
@@ -6,9 +6,6 @@
|
|||||||
|
|
||||||
%put %mf_existVarList(sashelp.class, age sex name dummyvar);
|
%put %mf_existVarList(sashelp.class, age sex name dummyvar);
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
|
||||||
@li mf_abort.sas
|
|
||||||
|
|
||||||
@param libds 2 part dataset or view reference
|
@param libds 2 part dataset or view reference
|
||||||
@param varlist space separated variable names
|
@param varlist space separated variable names
|
||||||
|
|
||||||
|
|||||||
@@ -23,18 +23,19 @@
|
|||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mf_getuser(type=META
|
%macro mf_getuser(
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
%local user metavar;
|
%local user;
|
||||||
%if &type=OS %then %let metavar=_secureusername;
|
|
||||||
%else %let metavar=_metaperson;
|
|
||||||
|
|
||||||
%if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER;
|
%if %symexist(_sasjs_username) %then %let user=&_sasjs_username;
|
||||||
%else %if %symexist(&metavar) %then %do;
|
%else %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %do;
|
||||||
%if %length(&&&metavar)=0 %then %let user=&sysuserid;
|
%let user=&SYS_COMPUTE_SESSION_OWNER;
|
||||||
|
%end;
|
||||||
|
%else %if %symexist(_metaperson) %then %do;
|
||||||
|
%if %length(&_metaperson)=0 %then %let user=&sysuserid;
|
||||||
/* sometimes SAS will add @domain extension - remove for consistency */
|
/* sometimes SAS will add @domain extension - remove for consistency */
|
||||||
/* but be sure to quote in case of usernames with commas */
|
/* but be sure to quote in case of usernames with commas */
|
||||||
%else %let user=%unquote(%scan(%quote(&&&metavar),1,@));
|
%else %let user=%unquote(%scan(%quote(&_metaperson),1,@));
|
||||||
%end;
|
%end;
|
||||||
%else %let user=&sysuserid;
|
%else %let user=&sysuserid;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
include, and then call \%mp_abort(mode=INCLUDE) from the source program (ie,
|
||||||
OUTSIDE of the top-parent macro).
|
OUTSIDE of the top-parent macro).
|
||||||
The soft abort has also been found to be ineffective in 9.4m6 windows
|
The soft abort has also been found to be ineffective in 9.4m6 windows
|
||||||
environments.
|
environments and above, so in these cases, endsas is used.
|
||||||
|
|
||||||
|
|
||||||
@param mac= (mp_abort.sas) To contain the name of the calling macro. Do not
|
@param mac= (mp_abort.sas) To contain the name of the calling macro. Do not
|
||||||
@@ -63,219 +63,236 @@
|
|||||||
, mode=REGULAR
|
, mode=REGULAR
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
%global sysprocessmode sysprocessname;
|
%global sysprocessmode sysprocessname sasjs_stpsrv_header_loc sasjsprocessmode;
|
||||||
|
%local fref fid i;
|
||||||
|
|
||||||
%if not(%eval(%unquote(&iftrue))) %then %return;
|
%if not(%eval(%unquote(&iftrue))) %then %return;
|
||||||
|
|
||||||
%put NOTE: /// mp_abort macro executing //;
|
%put NOTE: /// mp_abort macro executing //;
|
||||||
%if %length(&mac)>0 %then %put NOTE- called by &mac;
|
%if %length(&mac)>0 %then %put NOTE- called by &mac;
|
||||||
%put NOTE - &msg;
|
%put NOTE - &msg;
|
||||||
|
|
||||||
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
%if %symexist(_SYSINCLUDEFILEDEVICE)
|
||||||
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
/* abort cancel FILE does not restart outside the INCLUDE on Viya 3.5 */
|
||||||
and "&SYSPROCESSNAME " ne "Compute Server "
|
and %superq(SYSPROCESSNAME) ne %str(Compute Server)
|
||||||
|
%then %do;
|
||||||
|
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
||||||
|
data &errds;
|
||||||
|
iftrue='1=1';
|
||||||
|
length mac $100 msg $5000;
|
||||||
|
mac=symget('mac');
|
||||||
|
msg=symget('msg');
|
||||||
|
run;
|
||||||
|
data _null_;
|
||||||
|
abort cancel FILE;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
/* Web App Context */
|
||||||
|
%if %symexist(_PROGRAM)
|
||||||
|
or %superq(SYSPROCESSNAME) = %str(Compute Server)
|
||||||
|
or &mode=INCLUDE
|
||||||
|
%then %do;
|
||||||
|
options obs=max replace mprint;
|
||||||
|
%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5"
|
||||||
%then %do;
|
%then %do;
|
||||||
%if "*&_SYSINCLUDEFILEDEVICE*" ne "**" %then %do;
|
options nosyntaxcheck;
|
||||||
data &errds;
|
%end;
|
||||||
iftrue='1=1';
|
|
||||||
length mac $100 msg $5000;
|
%if &mode=INCLUDE %then %do;
|
||||||
mac=symget('mac');
|
%if %sysfunc(exist(&errds))=1 %then %do;
|
||||||
msg=symget('msg');
|
|
||||||
run;
|
|
||||||
data _null_;
|
data _null_;
|
||||||
abort cancel FILE;
|
set &errds;
|
||||||
|
call symputx('iftrue',iftrue,'l');
|
||||||
|
call symputx('mac',mac,'l');
|
||||||
|
call symputx('msg',msg,'l');
|
||||||
|
putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
|
%if (&iftrue)=0 %then %return;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%put &sysmacroname: No include errors found;
|
||||||
%return;
|
%return;
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
/* Web App Context */
|
/* extract log errs / warns, if exist */
|
||||||
%if %symexist(_PROGRAM)
|
%local logloc logline;
|
||||||
or "&SYSPROCESSNAME "="Compute Server "
|
%global logmsg; /* capture global messages */
|
||||||
or &mode=INCLUDE
|
%if %symexist(SYSPRINTTOLOG) %then %let logloc=&SYSPRINTTOLOG;
|
||||||
%then %do;
|
%else %let logloc=%qsysfunc(getoption(LOG));
|
||||||
options obs=max replace mprint;
|
proc printto log=log;run;
|
||||||
%if "%substr(&sysver,1,1)" ne "4" and "%substr(&sysver,1,1)" ne "5"
|
%let logline=0;
|
||||||
%then %do;
|
%if %length(&logloc)>0 %then %do;
|
||||||
options nosyntaxcheck;
|
data _null_;
|
||||||
%end;
|
infile &logloc lrecl=5000;
|
||||||
|
input; putlog _infile_;
|
||||||
%if &mode=INCLUDE %then %do;
|
i=1;
|
||||||
%if %sysfunc(exist(&errds))=1 %then %do;
|
retain logonce 0;
|
||||||
data _null_;
|
if (
|
||||||
set &errds;
|
_infile_=:"%str(WARN)ING" or _infile_=:"%str(ERR)OR"
|
||||||
call symputx('iftrue',iftrue,'l');
|
) and logonce=0 then
|
||||||
call symputx('mac',mac,'l');
|
do;
|
||||||
call symputx('msg',msg,'l');
|
call symputx('logline',_n_);
|
||||||
putlog (_all_)(=);
|
logonce+1;
|
||||||
run;
|
end;
|
||||||
%if (&iftrue)=0 %then %return;
|
run;
|
||||||
%end;
|
/* capture log including lines BEFORE the err */
|
||||||
%else %do;
|
%if &logline>0 %then %do;
|
||||||
%put &sysmacroname: No include errors found;
|
|
||||||
%return;
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
/* extract log errs / warns, if exist */
|
|
||||||
%local logloc logline;
|
|
||||||
%global logmsg; /* capture global messages */
|
|
||||||
%if %symexist(SYSPRINTTOLOG) %then %let logloc=&SYSPRINTTOLOG;
|
|
||||||
%else %let logloc=%qsysfunc(getoption(LOG));
|
|
||||||
proc printto log=log;run;
|
|
||||||
%let logline=0;
|
|
||||||
%if %length(&logloc)>0 %then %do;
|
|
||||||
data _null_;
|
data _null_;
|
||||||
infile &logloc lrecl=5000;
|
infile &logloc lrecl=5000;
|
||||||
input; putlog _infile_;
|
input;
|
||||||
i=1;
|
i=1;
|
||||||
retain logonce 0;
|
stoploop=0;
|
||||||
if (
|
if _n_ ge &logline-15 and stoploop=0 then do until (i>22);
|
||||||
_infile_=:"%str(WARN)ING" or _infile_=:"%str(ERR)OR"
|
call symputx('logmsg',catx('\n',symget('logmsg'),_infile_));
|
||||||
) and logonce=0 then
|
|
||||||
do;
|
|
||||||
call symputx('logline',_n_);
|
|
||||||
logonce+1;
|
|
||||||
end;
|
|
||||||
run;
|
|
||||||
/* capture log including lines BEFORE the err */
|
|
||||||
%if &logline>0 %then %do;
|
|
||||||
data _null_;
|
|
||||||
infile &logloc lrecl=5000;
|
|
||||||
input;
|
input;
|
||||||
i=1;
|
i+1;
|
||||||
stoploop=0;
|
stoploop=1;
|
||||||
if _n_ ge &logline-15 and stoploop=0 then do until (i>22);
|
end;
|
||||||
call symputx('logmsg',catx('\n',symget('logmsg'),_infile_));
|
if stoploop=1 then stop;
|
||||||
input;
|
|
||||||
i+1;
|
|
||||||
stoploop=1;
|
|
||||||
end;
|
|
||||||
if stoploop=1 then stop;
|
|
||||||
run;
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
%if %symexist(SYS_JES_JOB_URI) %then %do;
|
|
||||||
/* setup webout */
|
|
||||||
OPTIONS NOBOMFILE;
|
|
||||||
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
|
|
||||||
filename _webout temp lrecl=999999 mod;
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
|
|
||||||
name="_webout.json" lrecl=999999 mod;
|
|
||||||
%end;
|
|
||||||
%end;
|
|
||||||
|
|
||||||
/* send response in SASjs JSON format */
|
|
||||||
data _null_;
|
|
||||||
file _webout mod lrecl=32000 encoding='utf-8';
|
|
||||||
length msg syswarningtext syserrortext $32767 ;
|
|
||||||
sasdatetime=datetime();
|
|
||||||
msg=symget('msg');
|
|
||||||
%if &logline>0 %then %do;
|
|
||||||
msg=cats(msg,'\n\nLog Extract:\n',symget('logmsg'));
|
|
||||||
%end;
|
|
||||||
/* escape the escapes */
|
|
||||||
msg=tranwrd(msg,'\','\\');
|
|
||||||
/* escape the quotes */
|
|
||||||
msg=tranwrd(msg,'"','\"');
|
|
||||||
/* ditch the CRLFs as chrome complains */
|
|
||||||
msg=compress(msg,,'kw');
|
|
||||||
/* quote without quoting the quotes (which are escaped instead) */
|
|
||||||
msg=cats('"',msg,'"');
|
|
||||||
if symexist('_debug') then debug=quote(trim(symget('_debug')));
|
|
||||||
else debug='""';
|
|
||||||
put '>>weboutBEGIN<<';
|
|
||||||
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
|
||||||
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
|
||||||
put ',"sasjsAbort" : [{';
|
|
||||||
put ' "MSG":' msg ;
|
|
||||||
put ' ,"MAC": "' "&mac" '"}]';
|
|
||||||
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
|
||||||
put ',"_DEBUG":' debug ;
|
|
||||||
if symexist('_metauser') then do;
|
|
||||||
_METAUSER=quote(trim(symget('_METAUSER')));
|
|
||||||
put ",""_METAUSER"": " _METAUSER;
|
|
||||||
_METAPERSON=quote(trim(symget('_METAPERSON')));
|
|
||||||
put ',"_METAPERSON": ' _METAPERSON;
|
|
||||||
end;
|
|
||||||
if symexist('SYS_JES_JOB_URI') then do;
|
|
||||||
SYS_JES_JOB_URI=quote(trim(symget('SYS_JES_JOB_URI')));
|
|
||||||
put ',"SYS_JES_JOB_URI": ' SYS_JES_JOB_URI;
|
|
||||||
end;
|
|
||||||
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
|
||||||
syserrortext=quote(trim(symget('syserrortext')));
|
|
||||||
put ",""SYSERRORTEXT"" : " syserrortext;
|
|
||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
|
||||||
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
|
||||||
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
|
||||||
put ",""SYSSITE"" : ""&syssite"" ";
|
|
||||||
sysvlong=quote(trim(symget('sysvlong')));
|
|
||||||
put ',"SYSVLONG" : ' sysvlong;
|
|
||||||
syswarningtext=quote(trim(symget('syswarningtext')));
|
|
||||||
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
|
||||||
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
|
||||||
put "}" @;
|
|
||||||
put '>>weboutEND<<';
|
|
||||||
run;
|
|
||||||
|
|
||||||
%put _all_;
|
|
||||||
|
|
||||||
%if "&sysprocessmode " = "SAS Stored Process Server " %then %do;
|
|
||||||
data _null_;
|
|
||||||
putlog 'stpsrvset program err and syscc';
|
|
||||||
rc=stpsrvset('program error', 0);
|
|
||||||
call symputx("syscc",0,"g");
|
|
||||||
run;
|
run;
|
||||||
%if &sysscp=WIN and "%substr(&sysvlong. ,1,9)"="9.04.01M6" %then %do;
|
|
||||||
/* skip approach (below) does not work on this OS / version combo */
|
|
||||||
endsas;
|
|
||||||
%end;
|
|
||||||
%else %do;
|
|
||||||
/**
|
|
||||||
* endsas kills 9.4m3 deployments by orphaning multibridges.
|
|
||||||
* Abort variants are ungraceful (non zero return code)
|
|
||||||
* This approach lets SAS run silently until the end :-)
|
|
||||||
* Caution - fails when called within a %include within a macro
|
|
||||||
* Use mp_include() to handle this.
|
|
||||||
*/
|
|
||||||
filename skip temp;
|
|
||||||
data _null_;
|
|
||||||
file skip;
|
|
||||||
put '%macro skip();';
|
|
||||||
comment '%mend skip; -> fix lint ';
|
|
||||||
put '%macro skippy();';
|
|
||||||
comment '%mend skippy; -> fix lint ';
|
|
||||||
run;
|
|
||||||
%inc skip;
|
|
||||||
%end;
|
|
||||||
%end;
|
%end;
|
||||||
%else %if "&sysprocessmode " = "SAS Compute Server " %then %do;
|
%end;
|
||||||
/* endsas kills the session making it harder to fetch results */
|
|
||||||
data _null_;
|
%if %symexist(SYS_JES_JOB_URI) %then %do;
|
||||||
syswarningtext=symget('syswarningtext');
|
/* setup webout for Viya */
|
||||||
syserrortext=symget('syserrortext');
|
options nobomfile;
|
||||||
abort_msg=symget('msg');
|
%if "X&SYS_JES_JOB_URI.X"="XX" %then %do;
|
||||||
syscc=symget('syscc');
|
filename _webout temp lrecl=999999 mod;
|
||||||
sysuserid=symget('sysuserid');
|
|
||||||
iftrue=symget('iftrue');
|
|
||||||
put (_all_)(/=);
|
|
||||||
call symputx('syscc',0);
|
|
||||||
abort cancel nolist;
|
|
||||||
run;
|
|
||||||
%end;
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%abort cancel;
|
filename _webout filesrvc parenturi="&SYS_JES_JOB_URI"
|
||||||
|
name="_webout.json" lrecl=999999 mod;
|
||||||
%end;
|
%end;
|
||||||
%end;
|
%end;
|
||||||
|
%else %if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc))=0 %then %do;
|
||||||
|
options nobomfile;
|
||||||
|
/* set up http header for SASjs Server */
|
||||||
|
%let fid=%sysfunc(fopen(&fref,A));
|
||||||
|
%if &fid=0 %then %do;
|
||||||
|
%put %str(ERR)OR: %sysfunc(sysmsg());
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
%let rc=%sysfunc(fput(&fid,%str(Content-Type: application/json)));
|
||||||
|
%let rc=%sysfunc(fwrite(&fid));
|
||||||
|
%let rc=%sysfunc(fclose(&fid));
|
||||||
|
%let rc=%sysfunc(filename(&fref));
|
||||||
|
%end;
|
||||||
|
|
||||||
|
/* send response in SASjs JSON format */
|
||||||
|
data _null_;
|
||||||
|
file _webout mod lrecl=32000 encoding='utf-8';
|
||||||
|
length msg syswarningtext syserrortext $32767 mode $10 ;
|
||||||
|
sasdatetime=datetime();
|
||||||
|
msg=symget('msg');
|
||||||
|
%if &logline>0 %then %do;
|
||||||
|
msg=cats(msg,'\n\nLog Extract:\n',symget('logmsg'));
|
||||||
|
%end;
|
||||||
|
/* escape the escapes */
|
||||||
|
msg=tranwrd(msg,'\','\\');
|
||||||
|
/* escape the quotes */
|
||||||
|
msg=tranwrd(msg,'"','\"');
|
||||||
|
/* ditch the CRLFs as chrome complains */
|
||||||
|
msg=compress(msg,,'kw');
|
||||||
|
/* quote without quoting the quotes (which are escaped instead) */
|
||||||
|
msg=cats('"',msg,'"');
|
||||||
|
if symexist('_debug') then debug=quote(trim(symget('_debug')));
|
||||||
|
else debug='""';
|
||||||
|
if symget('sasjsprocessmode')='Stored Program' then mode='SASJS';
|
||||||
|
if mode ne 'SASJS' then put '>>weboutBEGIN<<';
|
||||||
|
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
||||||
|
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
||||||
|
put ',"sasjsAbort" : [{';
|
||||||
|
put ' "MSG":' msg ;
|
||||||
|
put ' ,"MAC": "' "&mac" '"}]';
|
||||||
|
put ",""SYSUSERID"" : ""&sysuserid"" ";
|
||||||
|
put ',"_DEBUG":' debug ;
|
||||||
|
if symexist('_metauser') then do;
|
||||||
|
_METAUSER=quote(trim(symget('_METAUSER')));
|
||||||
|
put ",""_METAUSER"": " _METAUSER;
|
||||||
|
_METAPERSON=quote(trim(symget('_METAPERSON')));
|
||||||
|
put ',"_METAPERSON": ' _METAPERSON;
|
||||||
|
end;
|
||||||
|
if symexist('SYS_JES_JOB_URI') then do;
|
||||||
|
SYS_JES_JOB_URI=quote(trim(symget('SYS_JES_JOB_URI')));
|
||||||
|
put ',"SYS_JES_JOB_URI": ' SYS_JES_JOB_URI;
|
||||||
|
end;
|
||||||
|
_PROGRAM=quote(trim(resolve(symget('_PROGRAM'))));
|
||||||
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
|
syserrortext=quote(trim(symget('syserrortext')));
|
||||||
|
put ",""SYSERRORTEXT"" : " syserrortext;
|
||||||
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
|
put ",""SYSJOBID"" : ""&sysjobid"" ";
|
||||||
|
put ",""SYSSCPL"" : ""&sysscpl"" ";
|
||||||
|
put ",""SYSSITE"" : ""&syssite"" ";
|
||||||
|
sysvlong=quote(trim(symget('sysvlong')));
|
||||||
|
put ',"SYSVLONG" : ' sysvlong;
|
||||||
|
syswarningtext=quote(trim(symget('syswarningtext')));
|
||||||
|
put ",""SYSWARNINGTEXT"" : " syswarningtext;
|
||||||
|
put ',"END_DTTM" : "' "%sysfunc(datetime(),E8601DT26.6)" '" ';
|
||||||
|
put "}" ;
|
||||||
|
if mode ne 'SASJS' then put '>>weboutEND<<';
|
||||||
|
run;
|
||||||
|
|
||||||
|
%put _all_;
|
||||||
|
|
||||||
|
%if "&sysprocessmode " = "SAS Stored Process Server " %then %do;
|
||||||
|
data _null_;
|
||||||
|
putlog 'stpsrvset program err and syscc';
|
||||||
|
rc=stpsrvset('program error', 0);
|
||||||
|
call symputx("syscc",0,"g");
|
||||||
|
run;
|
||||||
|
%if &sysscp=WIN
|
||||||
|
and "%substr(%str(&sysvlong ),1,8)"="9.04.01M"
|
||||||
|
and "%substr(%str(&sysvlong ),9,1)">"5" %then %do;
|
||||||
|
/* skip approach (below) does not work in windows m6+ envs */
|
||||||
|
endsas;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
/**
|
||||||
|
* endsas kills 9.4m3 deployments by orphaning multibridges.
|
||||||
|
* Abort variants are ungraceful (non zero return code)
|
||||||
|
* This approach lets SAS run silently until the end :-)
|
||||||
|
* Caution - fails when called within a %include within a macro
|
||||||
|
* Use mp_include() to handle this.
|
||||||
|
*/
|
||||||
|
filename skip temp;
|
||||||
|
data _null_;
|
||||||
|
file skip;
|
||||||
|
put '%macro skip();';
|
||||||
|
comment '%mend skip; -> fix lint ';
|
||||||
|
put '%macro skippy();';
|
||||||
|
comment '%mend skippy; -> fix lint ';
|
||||||
|
run;
|
||||||
|
%inc skip;
|
||||||
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %if "&sysprocessmode " = "SAS Compute Server " %then %do;
|
||||||
|
/* endsas kills the session making it harder to fetch results */
|
||||||
|
data _null_;
|
||||||
|
syswarningtext=symget('syswarningtext');
|
||||||
|
syserrortext=symget('syserrortext');
|
||||||
|
abort_msg=symget('msg');
|
||||||
|
syscc=symget('syscc');
|
||||||
|
sysuserid=symget('sysuserid');
|
||||||
|
iftrue=symget('iftrue');
|
||||||
|
put (_all_)(/=);
|
||||||
|
call symputx('syscc',0);
|
||||||
|
abort cancel nolist;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
%else %do;
|
%else %do;
|
||||||
%put _all_;
|
|
||||||
%abort cancel;
|
%abort cancel;
|
||||||
%end;
|
%end;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
%put _all_;
|
||||||
|
%abort cancel;
|
||||||
|
%end;
|
||||||
%mend mp_abort;
|
%mend mp_abort;
|
||||||
|
|
||||||
/** @endcond */
|
/** @endcond */
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
@cond
|
@cond
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mp_ds2cards(base_ds=, tgt_ds=
|
%macro mp_ds2cards(base_ds, tgt_ds=
|
||||||
,cards_file="%sysfunc(pathname(work))/cardgen.sas"
|
,cards_file="%sysfunc(pathname(work))/cardgen.sas"
|
||||||
,maxobs=max
|
,maxobs=max
|
||||||
,random_sample=NO
|
,random_sample=NO
|
||||||
@@ -254,6 +254,7 @@ data _null_;
|
|||||||
;
|
;
|
||||||
%end;
|
%end;
|
||||||
put ";";
|
put ";";
|
||||||
|
put 'missing a b c d e f g h i j k l m n o p q r s t u v w x y z _;';
|
||||||
put "datalines4;";
|
put "datalines4;";
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@
|
|||||||
do i=1 to &numcols;
|
do i=1 to &numcols;
|
||||||
name=quote(trim(symget(cats('name',i))));
|
name=quote(trim(symget(cats('name',i))));
|
||||||
format=quote(trim(symget(cats('fmt',i))));
|
format=quote(trim(symget(cats('fmt',i))));
|
||||||
label=quote(trim(symget(cats('label',i))));
|
label=quote(prxchange('s/\\/\\\\/',-1,trim(symget(cats('label',i)))));
|
||||||
length=quote(trim(symget(cats('length',i))));
|
length=quote(trim(symget(cats('length',i))));
|
||||||
type=quote(trim(symget(cats('typelong',i))));
|
type=quote(trim(symget(cats('typelong',i))));
|
||||||
if i>1 then put "," @@;
|
if i>1 then put "," @@;
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
@file mm_adduser2group.sas
|
@file mm_adduser2group.sas
|
||||||
@brief Adds a user to a group
|
@brief Adds a user to a group
|
||||||
@details Adds a user to a metadata group. The macro first checks whether the
|
@details Adds a user to a metadata group. The macro first checks whether the
|
||||||
user is in that group, and if not, the user is added.
|
user is in that group, and if not, the user is added.
|
||||||
|
|
||||||
|
Note that the macro does not check inherited group memberships - it looks at
|
||||||
|
direct members only.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -12,10 +15,10 @@
|
|||||||
|
|
||||||
@param user= the user name (not displayname)
|
@param user= the user name (not displayname)
|
||||||
@param group= the group to which to add the user
|
@param group= the group to which to add the user
|
||||||
@param mdebug= set to 1 to show debug info in log
|
@param mdebug= (0) set to 1 to show debug info in log
|
||||||
|
|
||||||
@warning the macro does not check inherited group memberships - it looks at
|
<h4> Related Files </h4>
|
||||||
direct members only
|
@li ms_adduser2group.sas
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ data _null_;
|
|||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -315,18 +315,19 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%mend mp_jsonout; ';
|
put '%mend mp_jsonout; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%macro mf_getuser(type=META ';
|
put '%macro mf_getuser( ';
|
||||||
put ')/*/STORE SOURCE*/; ';
|
put ')/*/STORE SOURCE*/; ';
|
||||||
put ' %local user metavar; ';
|
put ' %local user; ';
|
||||||
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
||||||
put ' %else %let metavar=_metaperson; ';
|
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
put ' %if %symexist(_sasjs_username) %then %let user=&_sasjs_username; ';
|
||||||
put ' %else %if %symexist(&metavar) %then %do; ';
|
put ' %else %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %do; ';
|
||||||
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
put ' %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
||||||
|
put ' %end; ';
|
||||||
|
put ' %else %if %symexist(_metaperson) %then %do; ';
|
||||||
|
put ' %if %length(&_metaperson)=0 %then %let user=&sysuserid; ';
|
||||||
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
||||||
put ' /* but be sure to quote in case of usernames with commas */ ';
|
put ' /* but be sure to quote in case of usernames with commas */ ';
|
||||||
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
put ' %else %let user=%unquote(%scan(%quote(&_metaperson),1,@)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %let user=&sysuserid; ';
|
put ' %else %let user=&sysuserid; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
@@ -451,6 +452,7 @@ data _null_;
|
|||||||
put ' put '',"_METAPERSON": '' _METAPERSON; ';
|
put ' put '',"_METAPERSON": '' _METAPERSON; ';
|
||||||
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
put ' put ",""SYSHOSTNAME"" : ""&syshostname"" "; ';
|
||||||
|
|||||||
@@ -8,17 +8,18 @@
|
|||||||
|
|
||||||
%mm_getusers()
|
%mm_getusers()
|
||||||
|
|
||||||
|
Optionally, filter for a user (useful to get the uri):
|
||||||
|
|
||||||
|
%mm_getusers(user=&_metaperson)
|
||||||
|
|
||||||
@param outds the dataset to create that contains the list of libraries
|
@param outds the dataset to create that contains the list of libraries
|
||||||
|
|
||||||
@returns outds dataset containing all users, with the following columns:
|
@returns outds dataset containing all users, with the following columns:
|
||||||
- uri
|
- uri
|
||||||
- name
|
- name
|
||||||
|
|
||||||
@warning The following filenames are created and then de-assigned:
|
@param user= (0) Set to a metadata user to filter on that user
|
||||||
|
@param outds= (work.mm_getusers) The output table to create
|
||||||
filename sxlemap clear;
|
|
||||||
filename response clear;
|
|
||||||
libname _XML_ clear;
|
|
||||||
|
|
||||||
@version 9.3
|
@version 9.3
|
||||||
@author Allan Bowe
|
@author Allan Bowe
|
||||||
@@ -26,23 +27,49 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
%macro mm_getusers(
|
%macro mm_getusers(
|
||||||
outds=work.mm_getusers
|
outds=work.mm_getusers,
|
||||||
|
user=0
|
||||||
)/*/STORE SOURCE*/;
|
)/*/STORE SOURCE*/;
|
||||||
|
|
||||||
filename response temp;
|
filename response temp;
|
||||||
proc metadata in= '<GetMetadataObjects>
|
%if %superq(user)=0 %then %do;
|
||||||
<Reposid>$METAREPOSITORY</Reposid>
|
proc metadata in= '<GetMetadataObjects>
|
||||||
<Type>Person</Type>
|
<Reposid>$METAREPOSITORY</Reposid>
|
||||||
<NS>SAS</NS>
|
<Type>Person</Type>
|
||||||
<Flags>0</Flags>
|
<NS>SAS</NS>
|
||||||
<Options>
|
<Flags>0</Flags>
|
||||||
<Templates>
|
<Options>
|
||||||
<Person Name=""/>
|
<Templates>
|
||||||
</Templates>
|
<Person Name=""/>
|
||||||
</Options>
|
</Templates>
|
||||||
</GetMetadataObjects>'
|
</Options>
|
||||||
out=response;
|
</GetMetadataObjects>'
|
||||||
run;
|
out=response;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
filename inref temp;
|
||||||
|
data _null_;
|
||||||
|
file inref;
|
||||||
|
put "<GetMetadataObjects>";
|
||||||
|
put "<Reposid>$METAREPOSITORY</Reposid>";
|
||||||
|
put "<Type>Person</Type>";
|
||||||
|
put "<NS>SAS</NS>";
|
||||||
|
put "<!-- Specify the OMI_XMLSELECT (128) flag -->";
|
||||||
|
put "<Flags>128</Flags>";
|
||||||
|
put "<Options>";
|
||||||
|
put "<Templates>";
|
||||||
|
put '<Person Name=""/>';
|
||||||
|
put "</Templates>";
|
||||||
|
length string $10000;
|
||||||
|
string=cats('<XMLSELECT search="Person[@Name=',"'&user'",']"/>');
|
||||||
|
put string;
|
||||||
|
put "</Options>";
|
||||||
|
put "</GetMetadataObjects>";
|
||||||
|
run;
|
||||||
|
proc metadata in=inref out=response;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
filename sxlemap temp;
|
filename sxlemap temp;
|
||||||
data _null_;
|
data _null_;
|
||||||
|
|||||||
@@ -157,6 +157,7 @@
|
|||||||
put ',"_METAPERSON": ' _METAPERSON;
|
put ',"_METAPERSON": ' _METAPERSON;
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
put ",""SYSHOSTNAME"" : ""&syshostname"" ";
|
||||||
|
|||||||
@@ -67,7 +67,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "server",
|
"name": "server",
|
||||||
"serverUrl": "https://sas.analytium.co.uk:5007",
|
|
||||||
"serverType": "SASJS",
|
"serverType": "SASJS",
|
||||||
"httpsAgentOptions": {
|
"httpsAgentOptions": {
|
||||||
"allowInsecureRequests": false
|
"allowInsecureRequests": false
|
||||||
@@ -107,4 +106,4 @@
|
|||||||
"contextName": "SAS Job Execution compute context"
|
"contextName": "SAS Job Execution compute context"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
122
server/ms_adduser2group.sas
Normal file
122
server/ms_adduser2group.sas
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Adds a user to a group on SASjs Server
|
||||||
|
@details Adds a user to a group based on userid and groupid. Both user and
|
||||||
|
group must already exist.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
%ms_adduser2group(uid=1,gid=1)
|
||||||
|
|
||||||
|
|
||||||
|
@param [in] uid= (0) The User ID to be added
|
||||||
|
@param [in] gid= (0) The Group ID to contain the new user
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [out] outds= (work.ms_adduser2group) This output dataset will contain
|
||||||
|
the new list of group members, eg:
|
||||||
|
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
||||||
|
|---|---|---|
|
||||||
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
|
|`Mihajlo Medjedovic `|`mihajlo `|`3`|
|
||||||
|
|`Ivor Townsend `|`ivor `|`4`|
|
||||||
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquefileref.sas
|
||||||
|
@li mf_getuniquelibref.sas
|
||||||
|
@li mp_abort.sas
|
||||||
|
|
||||||
|
<h4> Related Files </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_createuser.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro ms_adduser2group(uid=0
|
||||||
|
,gid=0
|
||||||
|
,outds=work.ms_adduser2group
|
||||||
|
,mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
|
)
|
||||||
|
|
||||||
|
%local fref0 fref1 fref2 libref optval rc msg;
|
||||||
|
%let fref0=%mf_getuniquefileref();
|
||||||
|
%let fref1=%mf_getuniquefileref();
|
||||||
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
/* avoid sending bom marker to API */
|
||||||
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
|
options nobomfile;
|
||||||
|
|
||||||
|
data _null_;
|
||||||
|
file &fref0 lrecl=1000;
|
||||||
|
infile "&_sasjs_tokenfile" lrecl=1000;
|
||||||
|
input;
|
||||||
|
if _n_=1 then put "accept: application/json";
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
%put _local_;
|
||||||
|
data _null_;
|
||||||
|
infile &fref0;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
proc http method='POST' headerin=&fref0 out=&fref1
|
||||||
|
url="&_sasjs_apiserverurl/SASjsApi/group/&gid/&uid";
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
debug level=1;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_adduser2group.sas
|
||||||
|
,msg=%str(Issue submitting query to SASjsApi/group)
|
||||||
|
)
|
||||||
|
|
||||||
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
|
data &outds;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
%if &mdebug=1 %then %do;
|
||||||
|
putlog _all_;
|
||||||
|
%end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
|
||||||
|
%mp_abort(
|
||||||
|
iftrue=(&syscc ne 0)
|
||||||
|
,mac=ms_creategroup.sas
|
||||||
|
,msg=%str(Issue reading response JSON)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* reset options */
|
||||||
|
options &optval;
|
||||||
|
|
||||||
|
%if &mdebug=0 %then %do;
|
||||||
|
filename &fref0 clear;
|
||||||
|
filename &fref1 clear;
|
||||||
|
libname &libref clear;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data _null_;
|
||||||
|
infile &fref1;
|
||||||
|
input;
|
||||||
|
putlog _infile_;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%mend ms_adduser2group;
|
||||||
@@ -298,7 +298,7 @@ data _null_;
|
|||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -317,18 +317,19 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%mend mp_jsonout; ';
|
put '%mend mp_jsonout; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%macro mf_getuser(type=META ';
|
put '%macro mf_getuser( ';
|
||||||
put ')/*/STORE SOURCE*/; ';
|
put ')/*/STORE SOURCE*/; ';
|
||||||
put ' %local user metavar; ';
|
put ' %local user; ';
|
||||||
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
||||||
put ' %else %let metavar=_metaperson; ';
|
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
put ' %if %symexist(_sasjs_username) %then %let user=&_sasjs_username; ';
|
||||||
put ' %else %if %symexist(&metavar) %then %do; ';
|
put ' %else %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %do; ';
|
||||||
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
put ' %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
||||||
|
put ' %end; ';
|
||||||
|
put ' %else %if %symexist(_metaperson) %then %do; ';
|
||||||
|
put ' %if %length(&_metaperson)=0 %then %let user=&sysuserid; ';
|
||||||
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
||||||
put ' /* but be sure to quote in case of usernames with commas */ ';
|
put ' /* but be sure to quote in case of usernames with commas */ ';
|
||||||
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
put ' %else %let user=%unquote(%scan(%quote(&_metaperson),1,@)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %let user=&sysuserid; ';
|
put ' %else %let user=&sysuserid; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
@@ -443,6 +444,7 @@ data _null_;
|
|||||||
put ' put ",""_DEBUG"" : ""&_debug"" "; ';
|
put ' put ",""_DEBUG"" : ""&_debug"" "; ';
|
||||||
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
put ' put '',"_PROGRAM" : '' _PROGRAM ; ';
|
||||||
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
put ' put ",""SYSCC"" : ""&syscc"" "; ';
|
||||||
|
put ' put ",""SYSENCODING"" : ""&sysencoding"" "; ';
|
||||||
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
put ' syserrortext=quote(cats(symget(''SYSERRORTEXT''))); ';
|
||||||
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
put ' put '',"SYSERRORTEXT" : '' syserrortext; ';
|
||||||
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
put ' SYSHOSTINFOLONG=quote(trim(symget(''SYSHOSTINFOLONG''))); ';
|
||||||
|
|||||||
@@ -2,13 +2,24 @@
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of groups from SASjs Server
|
@brief Fetches the list of groups from SASjs Server
|
||||||
@details Fetches the list of groups from SASjs Server and writes them to an
|
@details Fetches the list of groups from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Provide a username to filter for the groups for a particular
|
||||||
|
user.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getgroups(outds=userlist)
|
%ms_getgroups(outds=userlist)
|
||||||
|
|
||||||
|
With filter on username:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, user=James)
|
||||||
|
|
||||||
|
With filter on userid:
|
||||||
|
|
||||||
|
%ms_getgroups(outds=userlist, uid=1)
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] user= (0) Provide the username on which to filter
|
||||||
|
@param [in] uid= (0) Provide the userid on which to filter
|
||||||
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
@param [out] outds= (work.ms_getgroups) This output dataset will contain the
|
||||||
list of groups. Format:
|
list of groups. Format:
|
||||||
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
|NAME:$32.|DESCRIPTION:$64.|GROUPID:best.|
|
||||||
@@ -25,22 +36,38 @@
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_creategroup.sas
|
@li ms_creategroup.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getgroups.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getgroups(
|
%macro ms_getgroups(
|
||||||
outds=work.ms_getgroups
|
user=0,
|
||||||
,mdebug=0
|
uid=0,
|
||||||
);
|
outds=work.ms_getgroups,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
)
|
)
|
||||||
|
|
||||||
%local fref0 fref1 libref optval rc msg;
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
|
|
||||||
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
|
/* groups api does not exist in desktop mode */
|
||||||
|
data &outds;
|
||||||
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
|
name="&sysuserid";
|
||||||
|
description="&sysuserid (group - desktop mode)";
|
||||||
|
groupid=1;
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
%let fref0=%mf_getuniquefileref();
|
%let fref0=%mf_getuniquefileref();
|
||||||
%let fref1=%mf_getuniquefileref();
|
%let fref1=%mf_getuniquefileref();
|
||||||
%let libref=%mf_getuniquelibref();
|
%let libref=%mf_getuniquelibref();
|
||||||
@@ -65,8 +92,13 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%if "&user" ne "0" %then %let url=/SASjsApi/user/by/username/&user;
|
||||||
|
%else %if "&uid" ne "0" %then %let url=/SASjsApi/user/&uid;
|
||||||
|
%else %let url=/SASjsApi/group;
|
||||||
|
|
||||||
|
|
||||||
proc http method='GET' headerin=&fref0 out=&fref1
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/group";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
@@ -75,21 +107,31 @@ run;
|
|||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getgroups.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/group)
|
,msg=%str(Issue submitting GET query to SASjsApi)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&user"="0" and "&uid"="0" %then %do;
|
||||||
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
data &outds;
|
||||||
if _n_=1 then call missing(of _all_);
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
set &libref..root;
|
if _n_=1 then call missing(of _all_);
|
||||||
drop ordinal_root;
|
set &libref..root;
|
||||||
run;
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length NAME $32 DESCRIPTION $64. GROUPID 8;
|
||||||
|
if _n_=1 then call missing(of _all_);
|
||||||
|
set &libref..groups;
|
||||||
|
drop ordinal_:;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getgroups.sas
|
||||||
,msg=%str(Issue reading response JSON)
|
,msg=%str(Issue reading response JSON)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,26 @@
|
|||||||
@file
|
@file
|
||||||
@brief Fetches the list of users from SASjs Server
|
@brief Fetches the list of users from SASjs Server
|
||||||
@details Fetches the list of users from SASjs Server and writes them to an
|
@details Fetches the list of users from SASjs Server and writes them to an
|
||||||
output dataset.
|
output dataset. Can also be filtered, for a particular group.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
%ms_getusers(outds=userlist)
|
%ms_getusers(outds=userlist)
|
||||||
|
|
||||||
|
Filtering for a group by group name:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, group=GROUPNAME)
|
||||||
|
|
||||||
|
Filtering for a group by group id:
|
||||||
|
|
||||||
|
%ms_getusers(outds=work.groupmembers, gid=1)
|
||||||
|
|
||||||
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
@param [in] group= (0) Set to a group name to filter members for that group
|
||||||
|
@param [in] gid= (0) Set to a group id to filter members for that group
|
||||||
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
@param [out] outds= (work.ms_getusers) This output dataset will contain the
|
||||||
list of user accounts. Format:
|
list of user accounts. Format:
|
||||||
|DISPLAYNAME:$18.|USERNAME:$10.|ID:best.|
|
|DISPLAYNAME:$60.|USERNAME:$30.|ID:best.|
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|`Super Admin `|`secretuser `|`1`|
|
|`Super Admin `|`secretuser `|`1`|
|
||||||
|`Sabir Hassan`|`sabir`|`2`|
|
|`Sabir Hassan`|`sabir`|`2`|
|
||||||
@@ -20,7 +30,6 @@
|
|||||||
|`New User `|`newuser `|`5`|
|
|`New User `|`newuser `|`5`|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mf_getuniquefileref.sas
|
@li mf_getuniquefileref.sas
|
||||||
@li mf_getuniquelibref.sas
|
@li mf_getuniquelibref.sas
|
||||||
@@ -28,14 +37,17 @@
|
|||||||
|
|
||||||
<h4> Related Files </h4>
|
<h4> Related Files </h4>
|
||||||
@li ms_createuser.sas
|
@li ms_createuser.sas
|
||||||
|
@li ms_getgroups.sas
|
||||||
@li ms_getusers.test.sas
|
@li ms_getusers.test.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
%macro ms_getusers(
|
%macro ms_getusers(
|
||||||
outds=work.ms_getusers
|
outds=work.ms_getusers,
|
||||||
,mdebug=0
|
group=0,
|
||||||
);
|
gid=0,
|
||||||
|
mdebug=0
|
||||||
|
);
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
@@ -43,11 +55,24 @@
|
|||||||
,msg=%str(syscc=&syscc on macro entry)
|
,msg=%str(syscc=&syscc on macro entry)
|
||||||
)
|
)
|
||||||
|
|
||||||
%local fref0 fref1 libref optval rc msg;
|
%local fref0 fref1 libref optval rc msg url;
|
||||||
%let fref0=%mf_getuniquefileref();
|
%let fref0=%mf_getuniquefileref();
|
||||||
%let fref1=%mf_getuniquefileref();
|
%let fref1=%mf_getuniquefileref();
|
||||||
%let libref=%mf_getuniquelibref();
|
%let libref=%mf_getuniquelibref();
|
||||||
|
|
||||||
|
%if %sysget(MODE)=desktop %then %do;
|
||||||
|
/* users api does not exist in desktop mode */
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
USERNAME="&sysuserid";
|
||||||
|
DISPLAYNAME="&sysuserid (desktop mode)";
|
||||||
|
ID=1;
|
||||||
|
output;
|
||||||
|
stop;
|
||||||
|
run;
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
/* avoid sending bom marker to API */
|
/* avoid sending bom marker to API */
|
||||||
%let optval=%sysfunc(getoption(bomfile));
|
%let optval=%sysfunc(getoption(bomfile));
|
||||||
options nobomfile;
|
options nobomfile;
|
||||||
@@ -68,26 +93,40 @@ run;
|
|||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
%if "&group" ne "0" %then %let url=/SASjsApi/group/by/groupname/&group;
|
||||||
|
%else %if "&gid" ne "0" %then %let url=/SASjsApi/group/&gid;
|
||||||
|
%else %let url=/SASjsApi/user;
|
||||||
|
|
||||||
proc http method='GET' headerin=&fref0 out=&fref1
|
proc http method='GET' headerin=&fref0 out=&fref1
|
||||||
url="&_sasjs_apiserverurl/SASjsApi/user";
|
url="&_sasjs_apiserverurl.&url";
|
||||||
%if &mdebug=1 %then %do;
|
%if &mdebug=1 %then %do;
|
||||||
debug level=1;
|
debug level=1;
|
||||||
%end;
|
%end;
|
||||||
run;
|
run;
|
||||||
|
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
,mac=ms_getusers.sas
|
,mac=ms_getusers.sas
|
||||||
,msg=%str(Issue submitting GET query to SASjsApi/user)
|
,msg=%str(Issue submitting API query)
|
||||||
)
|
)
|
||||||
|
|
||||||
libname &libref JSON fileref=&fref1;
|
libname &libref JSON fileref=&fref1;
|
||||||
|
|
||||||
data &outds;
|
%if "&group"="0" and "&gid"="0" %then %do;
|
||||||
set &libref..root;
|
data &outds;
|
||||||
drop ordinal_root;
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
run;
|
set &libref..root;
|
||||||
|
drop ordinal_root;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
%else %do;
|
||||||
|
data &outds;
|
||||||
|
length DISPLAYNAME $60 USERNAME:$30 ID 8;
|
||||||
|
set &libref..users;
|
||||||
|
drop ordinal_root ordinal_users;
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mp_abort(
|
%mp_abort(
|
||||||
iftrue=(&syscc ne 0)
|
iftrue=(&syscc ne 0)
|
||||||
|
|||||||
@@ -153,6 +153,7 @@
|
|||||||
put ",""_DEBUG"" : ""&_debug"" ";
|
put ",""_DEBUG"" : ""&_debug"" ";
|
||||||
put ',"_PROGRAM" : ' _PROGRAM ;
|
put ',"_PROGRAM" : ' _PROGRAM ;
|
||||||
put ",""SYSCC"" : ""&syscc"" ";
|
put ",""SYSCC"" : ""&syscc"" ";
|
||||||
|
put ",""SYSENCODING"" : ""&sysencoding"" ";
|
||||||
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
syserrortext=quote(cats(symget('SYSERRORTEXT')));
|
||||||
put ',"SYSERRORTEXT" : ' syserrortext;
|
put ',"SYSERRORTEXT" : ' syserrortext;
|
||||||
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
SYSHOSTINFOLONG=quote(trim(symget('SYSHOSTINFOLONG')));
|
||||||
|
|||||||
52
tests/serveronly/ms_adduser2group.test.sas
Normal file
52
tests/serveronly/ms_adduser2group.test.sas
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing ms_adduser2group.sas macro
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
/* first, create an empty group */
|
||||||
|
%let group=%substr(%mf_getuniquename(),1,8);
|
||||||
|
%ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1a)
|
||||||
|
%let groupid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test1a;
|
||||||
|
call symputx('groupid',groupid);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&groupid>0),
|
||||||
|
desc=Checking that group was created with an ID,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
/* now add a user (user 1 always exists) */
|
||||||
|
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%ms_adduser2group(uid=1,gid=&groupid,mdebug=&sasjs_mdebug,outds=test1)
|
||||||
|
%mp_assertscope(COMPARE
|
||||||
|
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
||||||
|
)
|
||||||
|
|
||||||
|
/* check the user is in the output list */
|
||||||
|
%let checkid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test1;
|
||||||
|
if id=1 then call symputx('checkid',1);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&checkid=1),
|
||||||
|
desc=Checking that user was created in the new group,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ run;
|
|||||||
%let checkid=0;
|
%let checkid=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set work.test2;
|
set work.test2;
|
||||||
where name="&group";
|
where upcase(name)="%upcase(&group)";
|
||||||
call symputx('checkid',groupid);
|
call symputx('checkid',groupid);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
data _null_;
|
data _null_;
|
||||||
set work.test1;
|
set work.test1;
|
||||||
call symputx('id',id);
|
call symputx('id',id);
|
||||||
|
putlog (_all_)(=);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
iftrue=(&id>0),
|
iftrue=(&id>0),
|
||||||
@@ -35,7 +36,8 @@ run;
|
|||||||
%let checkid=0;
|
%let checkid=0;
|
||||||
data _null_;
|
data _null_;
|
||||||
set work.test2;
|
set work.test2;
|
||||||
where username="&user";
|
if _n_<20 then putlog (_all_)(=);
|
||||||
|
if upcase(username)="%upcase(&user)";
|
||||||
call symputx('checkid',id);
|
call symputx('checkid',id);
|
||||||
run;
|
run;
|
||||||
%mp_assert(
|
%mp_assert(
|
||||||
|
|||||||
@@ -3,21 +3,64 @@
|
|||||||
@brief Testing ms_getgroups.sas macro
|
@brief Testing ms_getgroups.sas macro
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_getuniquename.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
|
@li ms_creategroup.sas
|
||||||
@li ms_getgroups.sas
|
@li ms_getgroups.sas
|
||||||
|
@li mp_assert.sas
|
||||||
@li mp_assertdsobs.sas
|
@li mp_assertdsobs.sas
|
||||||
@li mp_assertscope.sas
|
@li mp_assertscope.sas
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
/* create a group */
|
||||||
|
%let group=%substr(%mf_getuniquename(),1,8);
|
||||||
|
%ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1)
|
||||||
|
|
||||||
|
/* get groups */
|
||||||
%mp_assertscope(SNAPSHOT)
|
%mp_assertscope(SNAPSHOT)
|
||||||
%ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
|
%ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
|
||||||
%mp_assertscope(COMPARE
|
%mp_assertscope(COMPARE
|
||||||
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADPNUM MCLIB0_JADVLEN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/* check the group was created */
|
||||||
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
||||||
|
|
||||||
|
%let test2=0;
|
||||||
|
%put &=group;
|
||||||
|
data _null_;
|
||||||
|
set work.test1;
|
||||||
|
putlog (_all_)(=);
|
||||||
|
if upcase(name)="%upcase(&group)" then do;
|
||||||
|
putlog "&group found!";
|
||||||
|
call symputx('test2',1);
|
||||||
|
call symputx('gid',groupid); /* used in next test */
|
||||||
|
end;
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test2"="1"),
|
||||||
|
desc=Checking group was created,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/* now check if the filter for the groups for a user works */
|
||||||
|
|
||||||
|
/* add a member */
|
||||||
|
%ms_adduser2group(uid=1,gid=&gid)
|
||||||
|
|
||||||
|
%ms_getgroups(user=secretuser,outds=work.test3)
|
||||||
|
|
||||||
|
%let test3=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test3;
|
||||||
|
if groupid=&gid then call symputx('test3',1);
|
||||||
|
run;
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=("&test3"="1"),
|
||||||
|
desc=Checking group list was returned for a user,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
@brief Testing ms_getusers.sas macro
|
@brief Testing ms_getusers.sas macro
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
|
@li ms_creategroup.sas
|
||||||
|
@li ms_adduser2group.sas
|
||||||
@li ms_getusers.sas
|
@li ms_getusers.sas
|
||||||
@li mp_assertdsobs.sas
|
@li mp_assertdsobs.sas
|
||||||
@li mp_assertscope.sas
|
@li mp_assertscope.sas
|
||||||
@@ -18,6 +20,39 @@
|
|||||||
|
|
||||||
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
%mp_assertdsobs(work.test1,test=ATLEAST 1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test the extraction of group members
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* create a group */
|
||||||
|
%let group=%substr(%mf_getuniquename(),1,8);
|
||||||
|
%ms_creategroup(&group, desc=some desc,mdebug=&sasjs_mdebug,outds=work.group)
|
||||||
|
%let gid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.group;
|
||||||
|
call symputx('gid',groupid);
|
||||||
|
run;
|
||||||
|
|
||||||
|
/* add a member */
|
||||||
|
%ms_adduser2group(uid=1,gid=&gid)
|
||||||
|
|
||||||
|
/* extract the members */
|
||||||
|
%ms_getusers(group=&group,outds=test2)
|
||||||
|
|
||||||
|
/* check the user is in the output list */
|
||||||
|
%let checkid=0;
|
||||||
|
data _null_;
|
||||||
|
set work.test2;
|
||||||
|
if id=1 then call symputx('checkid',1);
|
||||||
|
run;
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(&checkid=1),
|
||||||
|
desc=Checking that admin user was created in the new group,
|
||||||
|
outds=work.test_results
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ options mprint;
|
|||||||
)
|
)
|
||||||
%mp_assertscope(COMPARE)
|
%mp_assertscope(COMPARE)
|
||||||
|
|
||||||
libname webeen json (weboot);
|
libname webeen json fileref=weboot;
|
||||||
|
|
||||||
data _null_;
|
data _null_;
|
||||||
infile weboot;
|
infile weboot;
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
filename ft15f001 temp;
|
filename ft15f001 temp;
|
||||||
parmcards4;
|
data _null_;
|
||||||
|
file ft15f001;
|
||||||
|
infile cards;
|
||||||
|
input;
|
||||||
|
put _infile_;
|
||||||
|
cards4;
|
||||||
%put Initialising sendObj: ;
|
%put Initialising sendObj: ;
|
||||||
%put _all_;
|
%put _all_;
|
||||||
%webout(FETCH)
|
%webout(FETCH)
|
||||||
@@ -27,6 +32,7 @@ parmcards4;
|
|||||||
%mend x; %x()
|
%mend x; %x()
|
||||||
%webout(CLOSE)
|
%webout(CLOSE)
|
||||||
;;;;
|
;;;;
|
||||||
|
run;
|
||||||
%put creating web service: &mcTestAppLoc/services;
|
%put creating web service: &mcTestAppLoc/services;
|
||||||
%ms_createwebservice(
|
%ms_createwebservice(
|
||||||
path=&mcTestAppLoc/services,
|
path=&mcTestAppLoc/services,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ run;
|
|||||||
%ms_webout(OBJ,datasets,fref=&fref)
|
%ms_webout(OBJ,datasets,fref=&fref)
|
||||||
%ms_webout(CLOSE,fref=&fref)
|
%ms_webout(CLOSE,fref=&fref)
|
||||||
|
|
||||||
libname test JSON (&fref);
|
libname test JSON fileref=&fref;
|
||||||
data root;
|
data root;
|
||||||
set test.root;
|
set test.root;
|
||||||
call symputx('checkval',sysvlong);
|
call symputx('checkval',sysvlong);
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ data _null_;
|
|||||||
put ' do i=1 to &numcols; ';
|
put ' do i=1 to &numcols; ';
|
||||||
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
put ' name=quote(trim(symget(cats(''name'',i)))); ';
|
||||||
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
put ' format=quote(trim(symget(cats(''fmt'',i)))); ';
|
||||||
put ' label=quote(trim(symget(cats(''label'',i)))); ';
|
put ' label=quote(prxchange(''s/\\/\\\\/'',-1,trim(symget(cats(''label'',i))))); ';
|
||||||
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
put ' length=quote(trim(symget(cats(''length'',i)))); ';
|
||||||
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
put ' type=quote(trim(symget(cats(''typelong'',i)))); ';
|
||||||
put ' if i>1 then put "," @@; ';
|
put ' if i>1 then put "," @@; ';
|
||||||
@@ -459,18 +459,19 @@ data _null_;
|
|||||||
put '%end; ';
|
put '%end; ';
|
||||||
put '%mend mp_jsonout; ';
|
put '%mend mp_jsonout; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
put '%macro mf_getuser(type=META ';
|
put '%macro mf_getuser( ';
|
||||||
put ')/*/STORE SOURCE*/; ';
|
put ')/*/STORE SOURCE*/; ';
|
||||||
put ' %local user metavar; ';
|
put ' %local user; ';
|
||||||
put ' %if &type=OS %then %let metavar=_secureusername; ';
|
|
||||||
put ' %else %let metavar=_metaperson; ';
|
|
||||||
put ' ';
|
put ' ';
|
||||||
put ' %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
put ' %if %symexist(_sasjs_username) %then %let user=&_sasjs_username; ';
|
||||||
put ' %else %if %symexist(&metavar) %then %do; ';
|
put ' %else %if %symexist(SYS_COMPUTE_SESSION_OWNER) %then %do; ';
|
||||||
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
|
put ' %let user=&SYS_COMPUTE_SESSION_OWNER; ';
|
||||||
|
put ' %end; ';
|
||||||
|
put ' %else %if %symexist(_metaperson) %then %do; ';
|
||||||
|
put ' %if %length(&_metaperson)=0 %then %let user=&sysuserid; ';
|
||||||
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
|
||||||
put ' /* but be sure to quote in case of usernames with commas */ ';
|
put ' /* but be sure to quote in case of usernames with commas */ ';
|
||||||
put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
|
put ' %else %let user=%unquote(%scan(%quote(&_metaperson),1,@)); ';
|
||||||
put ' %end; ';
|
put ' %end; ';
|
||||||
put ' %else %let user=&sysuserid; ';
|
put ' %else %let user=&sysuserid; ';
|
||||||
put ' ';
|
put ' ';
|
||||||
|
|||||||
Reference in New Issue
Block a user