1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-16 04:50:05 +00:00

add authdomain for odbc connection

This commit is contained in:
Rud Faden
2023-10-17 13:13:03 +02:00
parent 592f477063
commit 0a24f3ff7b

View File

@@ -31,41 +31,41 @@
@version 9.2 @version 9.2
@author Allan Bowe @author Allan Bowe
**/ **/
%macro mm_assigndirectlib( %macro mm_assigndirectlib(
libref libref
,open_passthrough= ,open_passthrough=
,sql_options= ,sql_options=
,mDebug=0 ,mDebug=0
,mAbort=0 ,mAbort=0
)/*/STORE SOURCE*/; )/*/STORE SOURCE*/;
%local mD; %local mD;
%if &mDebug=1 %then %let mD=; %if &mDebug=1 %then %let mD=;
%else %let mD=%str(*); %else %let mD=%str(*);
%&mD.put Executing mm_assigndirectlib.sas; %&mD.put Executing mm_assigndirectlib.sas;
%&mD.put _local_; %&mD.put _local_;
%if &mAbort=1 %then %let mAbort=; %if &mAbort=1 %then %let mAbort=;
%else %let mAbort=%str(*); %else %let mAbort=%str(*);
%&mD.put NOTE: Creating direct (non META) connection to &libref library; %&mD.put NOTE: Creating direct (non META) connection to &libref library;
%local cur_engine; %local cur_engine;
%let cur_engine=%mf_getengine(&libref); %let cur_engine=%mf_getengine(&libref);
%if &cur_engine ne META and &cur_engine ne %then %do; %if &cur_engine ne META and &cur_engine ne %then %do;
%put NOTE: &libref already has a direct (&cur_engine) libname connection; %put NOTE: &libref already has a direct (&cur_engine) libname connection;
%return; %return;
%end; %end;
%else %if %upcase(&libref)=WORK %then %do; %else %if %upcase(&libref)=WORK %then %do;
%put NOTE: We already have a direct connection to WORK :-) ; %put NOTE: We already have a direct connection to WORK :-) ;
%return; %return;
%end; %end;
/* need to determine the library ENGINE first */ /* need to determine the library ENGINE first */
%local engine; %local engine;
data _null_; data _null_;
length lib_uri engine $256; length lib_uri engine $256;
call missing (of _all_); call missing (of _all_);
/* get URI for the particular library */ /* get URI for the particular library */
@@ -75,10 +75,10 @@ data _null_;
putlog "mm_assigndirectlib for &libref:" rc1= lib_uri= rc2= engine=; putlog "mm_assigndirectlib for &libref:" rc1= lib_uri= rc2= engine=;
call symputx("liburi",lib_uri,'l'); call symputx("liburi",lib_uri,'l');
call symputx("engine",engine,'l'); call symputx("engine",engine,'l');
run; run;
/* now obtain engine specific connection details */ /* now obtain engine specific connection details */
%if &engine=BASE %then %do; %if &engine=BASE %then %do;
%&mD.put NOTE: Retrieving BASE library path; %&mD.put NOTE: Retrieving BASE library path;
data _null_; data _null_;
length up_uri $256 path cat_path $1024; length up_uri $256 path cat_path $1024;
@@ -112,8 +112,8 @@ run;
libname &libref &filepath filelockwait=5; libname &libref &filepath filelockwait=5;
%end; %end;
%end; %end;
%else %if &engine=REMOTE %then %do; %else %if &engine=REMOTE %then %do;
data x; data x;
length rcCon rcProp rc k 3 uriCon uriProp PropertyValue PropertyName length rcCon rcProp rc k 3 uriCon uriProp PropertyValue PropertyName
Delimiter $256 properties $2048; Delimiter $256 properties $2048;
@@ -143,9 +143,9 @@ run;
libname &libref &engine &properties slibref=&libref; libname &libref &engine &properties slibref=&libref;
%end; %end;
%else %if &engine=OLEDB %then %do; %else %if &engine=OLEDB %then %do;
%&mD.put NOTE: Retrieving OLEDB connection details; %&mD.put NOTE: Retrieving OLEDB connection details;
data _null_; data _null_;
length domain datasource provider properties schema length domain datasource provider properties schema
@@ -208,11 +208,11 @@ run;
%end; %end;
connection=shared; connection=shared;
%end; %end;
%end; %end;
%else %if &engine=ODBC %then %do; %else %if &engine=ODBC %then %do;
&mD.%put NOTE: Retrieving ODBC connection details; &mD.%put NOTE: Retrieving ODBC connection details;
data _null_; data _null_;
length connx_uri conprop_uri value datasource up_uri schema $256.; length domprop_uri authdomain connx_uri conprop_uri value datasource up_uri schema $256.;
call missing (of _all_); call missing (of _all_);
/* get source connection ID */ /* get source connection ID */
rc=metadata_getnasn("&liburi",'LibraryConnection',1,connx_uri); rc=metadata_getnasn("&liburi",'LibraryConnection',1,connx_uri);
@@ -226,11 +226,18 @@ run;
rc4=metadata_getattr(conprop_uri,'DefaultValue',datasource); rc4=metadata_getattr(conprop_uri,'DefaultValue',datasource);
rc2=-1; rc2=-1;
end; end;
end; end;
/* get auth domain */
autrc=metadata_getnasn(connx_uri,"Domain",1,domprop_uri);
arc=metadata_getattr(domprop_uri,"Name",authdomain);
call symputx('authdomain',authdomain,'l');
/* get SCHEMA */ /* get SCHEMA */
rc6=metadata_getnasn("&liburi",'UsingPackages',1,up_uri); rc6=metadata_getnasn("&liburi",'UsingPackages',1,up_uri);
rc7=metadata_getattr(up_uri,'SchemaName',schema); rc7=metadata_getattr(up_uri,'SchemaName',schema);
&mD.put rc= connx_uri= rc2= conprop_uri= rc3= value= rc4= datasource= &mD.put rc= connx_uri= rc2= conprop_uri= rc3= value= rc4= autrc= arc= datasource=
rc6= up_uri= rc7= schema=; rc6= up_uri= rc7= schema=;
call symputx('SQL_schema',schema,'l'); call symputx('SQL_schema',schema,'l');
@@ -243,10 +250,10 @@ run;
(INSERT_SQL=YES DATASRC=&sql_dsn. CONNECTION=global); (INSERT_SQL=YES DATASRC=&sql_dsn. CONNECTION=global);
%end; %end;
%else %do; %else %do;
libname &libref ODBC DATASRC=&sql_dsn SCHEMA=&sql_schema; libname &libref ODBC DATASRC=&sql_dsn SCHEMA=&sql_schema AUTHDOMAIN=&authdomain;
%end; %end;
%end; %end;
%else %if &engine=POSTGRES %then %do; %else %if &engine=POSTGRES %then %do;
%put NOTE: Obtaining POSTGRES library details; %put NOTE: Obtaining POSTGRES library details;
data _null_; data _null_;
length database ignore_read_only_columns direct_exe preserve_col_names length database ignore_read_only_columns direct_exe preserve_col_names
@@ -344,8 +351,8 @@ run;
&preserve_col_names &preserve_tab_names &server &schema &authdomain &preserve_col_names &preserve_tab_names &server &schema &authdomain
&user &password; &user &password;
%end; %end;
%end; %end;
%else %if &engine=ORACLE %then %do; %else %if &engine=ORACLE %then %do;
%put NOTE: Obtaining &engine library details; %put NOTE: Obtaining &engine library details;
data _null_; data _null_;
length assocuri1 assocuri2 assocuri3 authdomain path schema $256; length assocuri1 assocuri2 assocuri3 authdomain path schema $256;
@@ -372,8 +379,8 @@ run;
%put NOTE- authdomain=&authdomain; %put NOTE- authdomain=&authdomain;
%put NOTE-; %put NOTE-;
libname &libref ORACLE path=&path schema=&schema authdomain=&authdomain; libname &libref ORACLE path=&path schema=&schema authdomain=&authdomain;
%end; %end;
%else %if &engine=SQLSVR %then %do; %else %if &engine=SQLSVR %then %do;
%put NOTE: Obtaining &engine library details; %put NOTE: Obtaining &engine library details;
data _null; data _null;
length assocuri1 assocuri2 assocuri3 authdomain path schema userid length assocuri1 assocuri2 assocuri3 authdomain path schema userid
@@ -404,8 +411,8 @@ run;
%put NOTE-; %put NOTE-;
libname &libref SQLSVR datasrc=&path schema=&schema user="&user" pass="&pass"; libname &libref SQLSVR datasrc=&path schema=&schema user="&user" pass="&pass";
%end; %end;
%else %if &engine=TERADATA %then %do; %else %if &engine=TERADATA %then %do;
%put NOTE: Obtaining &engine library details; %put NOTE: Obtaining &engine library details;
data _null; data _null;
length assocuri1 assocuri2 assocuri3 authdomain path schema userid length assocuri1 assocuri2 assocuri3 authdomain path schema userid
@@ -444,18 +451,18 @@ run;
%put NOTE-; %put NOTE-;
libname &libref TERADATA server="&path" schema=&schema authdomain=&authdomain; libname &libref TERADATA server="&path" schema=&schema authdomain=&authdomain;
%end; %end;
%else %if &engine= %then %do; %else %if &engine= %then %do;
%put NOTE: Libref &libref is not registered in metadata; %put NOTE: Libref &libref is not registered in metadata;
%&mAbort.mp_abort( %&mAbort.mp_abort(
msg=%str(ERR)OR: Libref &libref is not registered in metadata msg=%str(ERR)OR: Libref &libref is not registered in metadata
,mac=mm_assigndirectlib.sas); ,mac=mm_assigndirectlib.sas);
%return; %return;
%end; %end;
%else %do; %else %do;
%put %str(WARN)ING: Engine &engine is currently unsupported; %put %str(WARN)ING: Engine &engine is currently unsupported;
%put %str(WARN)ING- Please contact your support team.; %put %str(WARN)ING- Please contact your support team.;
%return; %return;
%end; %end;
%mend mm_assigndirectlib; %mend mm_assigndirectlib;