The SAS knowledge base provides useful examples how to retrieve several kinds of metadata One that attracted my attention was the program to list all libraries and their associated directory or database schema Since my requirement is to to list all libraries for all users and groups, I enhanced the program a little to loop through all logins and get all associated libraries (both Oracle databases and/or base directories) for each login. See code below. The result of running this program is a small list of connections to Oracle/ODBC libraries Since we have several SAS users with access to base directories, I would have expected to see them in this list too Any ideas or suggestions? ***my program*** data logins_libraries; length liburi loguri upasnuri uri0 $256 name $128 loginobjid identobjid type id $17 libref engine $8 path mdschemaname schema $256; keep loginobjid identobjid name libref engine path mdschemaname schema; call missing(liburi,loguri, upasnuri,name,engine,libref,loginobjid,identobjid); nlogobj=1; logrc=metadata_getnobj("omsobj:Login?@Id contains '.'",nlogobj,loguri); if logrc<=0 then put "NOTE: rc=" logrc "There are no Logins defined in this repository" " or there was an error reading the repository."; do while(logrc>0); rc=metadata_getattr(loguri,'Id',loginobjid); n0=1; airc=metadata_getnasn(loguri,"AssociatedIdentity",n0,uri0); if airc<=0 then put "NOTE: rc=" airc "There is no Person or Group associated with the " loginobjid "Login ID."; else do; arc=metadata_resolve(uri0,IdentType,IdentId); rc=metadata_getattr(uri0,'Id',identobjid); end; nlibobj=1; librc=metadata_getnasn(loguri,'Libraries',nlibobj,liburi); do while (librc>0); rc=metadata_getattr(liburi,'Name',name); rc=metadata_getattr(liburi,'Engine',engine); rc=metadata_getattr(liburi,'Libref',libref); n=1; uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri); if uprc > 0 then do; call missing(type,id,path,mdschemaname,schema); rc=metadata_resolve(upasnuri,type,id); if type='Directory' then do; rc=metadata_getattr(upasnuri,'DirectoryName',path); output; end; else if type='DatabaseSchema' then do; rc=metadata_getattr(upasnuri,'Name',mdschemaname); rc=metadata_getattr(upasnuri,'SchemaName',schema); output; end; n+1; uprc=metadata_getnasn(liburi,'UsingPackages',n,upasnuri); end; /* if uprc > 0 */ nlibobj+1; librc=metadata_getnasn(loguri,'Libraries',nlibobj,liburi); end; /* do while (librc>0) */ nlogobj+1; logrc=metadata_getnobj("omsobj:Login?@Id contains '.'",nlogobj,loguri); end; /* do while (logrc>0) */ run; proc sort data=logins_libraries NODUPRECS; run;
... View more