First, I would like to mention that I am not a SAS admin, I am a developer with some particular task to do, so I am asking also for your understanding 🙂
I am trying to select all users from our environment (in SAS EG). I found a lot of codes to do that in the net, for example here, in this community (https://communities.sas.com/t5/Administration-and-Deployment/Querying-the-metadata-for-a-list-of-use...). In general, I am trying to call the following function:
nobj = metadata_getnobj("omsobj:Person?@Id contains '.'",n,uri);
but in the result I have no records at all. When I change the above code to this one:
nobj = metadata_getnobj("omsobj:Login?@Id contains '.'",n,uri);
I am able to see only my login (with associated identity groups).
I would suspect that I don't have proper permissions, but when I go to SAS Management Console and I log-in using exactly the same credentials, I see a lot of users in the repository.
Do you have any ideas what should I do to see all users from code run in SAS EG?
Thanks in advance!
Hi @andreas_lds ,
Yes, sure - this is one of the code that I am running:
options metaserver="xxx" metaport=8561 metauser="xxx" metapass="xxx" metarepository="Foundation"; data fullList; length objName $60 objId $17 objType $50;; delete; run; %macro getMeta(objType); data temp(keep=objType objName objId); length uri $256 objName $60 objId $17 objType $50; uri="";n=1;TableName=""; objType="&objType"; do while(metadata_getnobj("omsobj:&objType?@Id ? '.'",n,uri) >= 0); rc=metadata_getattr(uri,"Name",objName); rc=metadata_getattr(uri,"Id",objId); n=n+1; output; end; run; proc append base=fullList data=temp; run; %mend; %getMeta(Person); %getMeta(Login); %getMeta(User); /* %getMeta(PhysicalTable);*/ /* %getMeta(RepositoryBase);*/ /* %getMeta(Machine);*/ /* %getMeta(sasLibrary);*/
The other one is from this community, you can find it here: https://communities.sas.com/t5/Administration-and-Deployment/Querying-the-metadata-for-a-list-of-use...
The code works like charm on my server with my normal / dev account. Of course, the last call with objType = User returns nothing, because the type doesn't exist. But Logins are returned for myself and i get all persons.
I have no explanation for the effect you have. If users are visible in smc, i can't think of anything that would prevent listing those user using code.
Note that what is returned depends on what the user connecting to Metadata has permission to see. You may want to try adding something to connect as the unrestricted user, like:
options metauser="sasadm@saspw" metapass="password";
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.