Thanx to Paul Holmes and Ron Fehd. for suggestions and examples.
Man - this stuff will twist your brains. The following code is a start
- still needs more error checking and diagnostics built in to it. But
we have a sort of lift-off. In the end I will probably run this as a
compiled datastep in everyone's autoexec so they cannot see the
underlying code.
One item that has become obvious is that we will need to define all our
datasets into the OMR which I was hoping to avoid due to the large
number of them - I was intending to define only those datasets we use to
build OLAP cubes. But if we are to use the META libname engine, then we
have to or we end up with a libname allocated, and no members (datasets)
for anyone to see.
options
metaserver="hostname"
metaport=8561
metaprotocol=bridge
metarepository="Foundation"
metauser="userid"
metapass="xxxxxx"
;
data _null_ ;
/*-- Define Lengths for all target variables --*/
length libraryCount 8
libraryUri
LibraryPath $200
uri $17
Repid
Libid
libraryRef $8;
/*-- Build up the OMR search String to get a list of libraries the
user is ALLOWED to see --*/
/*-- It is IMPORTANT that the quoting is axactly as is - do not
stuff around with it!! --*/
String='"omsobj:SASLibrary?*[AccessControls/AccessControlEntry[Identities/IdentityGroup'
||
"[MemberIdentities/Person[@Name='"||
Trim(sysget('LOGNAME')) ||"'"||']]]]"' ;
LibraryCount= 0;
/*-- Now loop thru extracting the META information for each
Library the user is --*/
/*-- allowed
access. --*/
do until (libraryCount < 0);
/*-- Accumulate the library counter we will allocate --*/
libraryIndex + 1;
libraryUri = '';
/*-- LibraryCOunt=How many libnames is the user allowed to
see --*/
/*-- LibraryIndex= the nth library we will extract &
allocate --*/
/*-- LibraryUri = the metadata id for the
library. --*/
libraryCount = metadata_getnobj(STRING ,
libraryIndex,
libraryUri
);
/*-- If the user is ALLOWED to see ANY libraries then allocate
them --*/
if ( libraryCount > 0 ) then do;
/*-- Pull the URI from the END of the LIbraryURI string --*/
uri=scan(Libraryuri,-1,'\') ;
/*-- Pull the REPOSITORY ID from the start of the URI --*/
repid=scan(uri,1,'.') ;
/*-- Pull the LIBRARY IF from the end of the URI --*/
libid=scan(uri,-1,'.') ;
/*-- Build the options necessary for the libname function --*/
Options='Repid="'||trim(repid) || '" LIBID="'||
trim(libid) || '"' ;
/*-- Determine what the LIBREF name we are to use --*/
_rc = metadata_getattr(libraryUri,"Libref",libraryRef);
/*-- Allocate the sucker using the META libname --*/
lrc=libname(libraryref,' ','META',options) ;
end;
/*-- Need some stuff in here to write messages when do not
allocate--*/
/*-- ANY libraries - possibly the OMR is down/not
accessible?? --*/
/*-- or we have an intruder who should not be on the
system?? --*/
/** If libraryIndex=1 and LibraryCount<0 then do ;
* Write messages to log ;
Putlog "Oopps - " ;
* Send email to control group - we have a problem
Houston ;
ENd ;
***/
end;
run;
>
>>-----Original Message-----
>>From: owner-sas-l@listserv.uga.edu
>>[mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Robin Templer
>>Sent: Sunday, April 30, 2006 2:27 AM
>>To: SAS-L@LISTSERV.UGA.EDU
>>Subject: SAS Metadata Repository, how to Extract libnames
>>
>>We are further implementing our Metadata repository, and want
>>to use the libnames defined in the OMR. Our issue is the
>>use of these libnames for users accessing sas via
>>SAS/Connect spawners and batch jobs. For EG users there is
>>not problem
>>
>>Does anyone have any examples of using code to extract a list
>>of libnames ??
>>
>>Environment:
>>-----------------
>>HPUX
>>SAS 9.1.3 SP4
>>
>>
>>Background:
>>----------------
>>We have approx. 214 libnames,
>>Access to the underlying libraries is controlled by unix groups.
>>Autoexec.sas is generated by the login process every time a
>>user logs in
>>- either via telnet, Connect Spawners or Object Spawners (EG).
>>
>>We want to move away from generating the autoexec.sas for
>>each user, and move to a more flexible approach using the OMR.
>>
>>
>>Any ideas/samples would be much appreciated.
>>
>>Robin
>>
>>
>>
>
>
|