BookmarkSubscribeRSS Feed
Albert0
Quartz | Level 8

Hi All,

 

I would like to ask on how can I extract all the User, Groups and Roles that are registered in SMC? I have this code below but when I trybto use it, it doesn't get me an output.

 

 

/*Connect to the metadata server*/
options metaserver="localhost"
metaport=8561
metauser="myuser"
metapass="mypassword"
metarepository="Foundation"
metaprotocol=BRIDGE;

data users_grps_roles;
length uri name DisplayName grp groupuri $256 grptype $5 id MDUpdate $20;

/*Initialize variables to missing*/
n=1;
uri='';
name='';
Displayname='';
grp='';
groupuri='';
grptype='';
id='';
MDUpdate='';

/*Determine how many person objects are defined*/
nobj=metadata_getnobj("omsobj:Person?@Id contains '.'",n,uri);

if nobj=0 then
put 'No Persons available.';
else
do while (nobj > 0);
/*Retrieve the current person's name*/
rc=metadata_getattr(uri, "Name", Name);

/*Retrieve the current person's displayname*/
rc=metadata_getattr(uri, "DisplayName", DisplayName);
rc=metadata_getattr(uri, "MetadataUpdated", MDUpdate);

/*Get the group association information for the current person*/
a=1;
grpassn=metadata_getnasn(uri,"IdentityGroups",a,groupuri);

/*If this person does not belong to any groups, set their group
variable to 'NONE'*/
if grpassn in (-3,-4) then
do;
grp="NONE";
output;
end;

/*If the person belongs to any groups, loop through the list
and retrieve the name of each group, outputting each on a
separate record. If the GroupType is a <blank>, then set the
grptype to GROUP. If the GroupType is a ROLE, then the
grptype is already set to ROLE. This will be used in the
PROC REPORT step.*/
else
do while (grpassn > 0);
rc2=metadata_getattr(groupuri, "Name", grp);
rc3=metadata_getattr(groupuri, "GroupType", grptype);

if grptype = '' then
do;
grptype="GROUP";
end;

output;
a+1;
grpassn=metadata_getnasn(uri,"IdentityGroups",a,groupuri);
end;

/*Retrieve the next person's information*/
n+1;
nobj=metadata_getnobj("omsobj:Person?@Id contains '.'",n,uri);
end;

keep name DisplayName MDUpdate grp grptype;
run;

options ls=200 ps=200;

/*Display the list of users and their groups*/
proc report data=users_grps_roles nowd headline headskip spanrows;
columns grptype grp name DisplayName groups roles MDUpdate;
define name / order 'User Name' format=$30.;
define DisplayName / order 'User DisplayName' format=$40.;
define grp / noprint;
define grptype / noprint;
define groups / computed 'Groups' format=$40.;
define roles / computed 'Roles' format=$40.;

compute groups / char length = 40;

if grptype = 'GROUP' then
groups = grp;
else if grp = 'NONE' then
groups = 'NONE';
else groups = ' ';
endcomp;

compute roles / char length = 40;

if grptype = 'ROLE' then
roles = grp;
else if grp = 'NONE' then
roles = 'NONE';
else roles = ' ';
endcomp;

define MDUpdate / display 'Last Updated' format=$20.;
break after name / skip;
title 'Listing of Users and associated Groups and Roles';
run;

 

Thank you.

 

-Albert

2 REPLIES 2
Albert0
Quartz | Level 8
Hi guys...I've managed to make the program worked

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2104 views
  • 0 likes
  • 2 in conversation