The `work.users` dataset is dynamically created and populated from information extracted from the SAS metadata server via the `metadata_getnobj` and `metadata_getattr` functions. There is no external data source to the script (file, database) or SASHELP dataset directly used as input.
1 Code Block
OPTIONS
Explanation : This block configures the connection options to the SAS metadata server. It specifies the server address (`metaserver`), port (`metaport`), user credentials (`metauser`, `metapass`), metadata repository (`metarepository`), and communication protocol (`metaprotocol`). This information is essential for establishing the connection and querying metadata.
Explanation : This `DATA STEP` block is responsible for creating the `work.users` dataset and populating it with user IDs. It declares and initializes the necessary variables. It uses `metadata_getnobj` to find the 'DefaultAuth' authentication domain and its URI, then `metadata_getattr` to retrieve its ID. Subsequently, a `do while` loop iterates through all Login objects associated with this domain. For each Login, the user ID (`UserID`) is extracted via `metadata_getattr` and added to the `work.users` dataset. Only the `user_id` variable is kept in the final dataset.
Copied!
data work.users; /* Create work.users library to house data. */
/* declare variables */
length
ad_uri $ 256
ad_id $ 256
login_uri $ 256
user_id $ 256;
/* initialize variables. */
call missing(ad_uri,ad_id,login_uri,user_id);
keep user_id; /* only keep the user ids in the table. */
n=1;
/* Get the URI for the DefaultAuth Authentication Domain. */
adrc=metadata_getnobj("omsobj:AuthenticationDomain? @code_sas_json_prod_multi/libname_de.json = 'DefaultAuth'",1,ad_uri);
rc=metadata_getattr(ad_uri,"Id",ad_id);
/* Get number of login objects that have the DefaultAuth authentication */
/* domain associated with them, as well as the URI of the first login. */
loginrc=metadata_getnobj("omsobj:Login?Login[Domain/AuthenticationDomain[ @Id='"||ad_id||"']",n,login_uri);
do while(loginrc>0);
/* extract the user ID from login */
rc=metadata_getattr(login_uri,"UserID",user_id);
output;
n+1;
/* Get the URI of the next login. */
loginrc=metadata_getnobj("omsobj:Login?Login[Domain/AuthenticationDomain[ @Id='"||ad_id||"']",n,login_uri);
end;
run;
1
DATA work.users; /* Create work.users library to house data. */
2
3
/* declare variables */
4
5
LENGTH
6
ad_uri $ 256
7
ad_id $ 256
8
login_uri $ 256
9
user_id $ 256;
10
11
/* initialize variables. */
12
13
call missing(ad_uri,ad_id,login_uri,user_id);
14
keep user_id; /* only keep the user ids in the table. */
15
16
n=1;
17
/* Get the URI for the DefaultAuth Authentication Domain. */
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author: Greg Wootton Date: 08FEB2017
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.