BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Santt0sh
Lapis Lazuli | Level 10

Hi,

 

I am trying to extract details of the users from Groups.

The details I am looking to extract are 

1. User name

2. user email

3 name of the group 

I have tried using the below mentioned,

 

 

 /* Use the META* options to specify the options for connecting to the */
   /* metadata server that contains the user information. */

options metaserver=zzzzzzzz123456.xxxxxbe.com 
                                       
        metaport=8561              

        metauser="metaxxxxxxxx"  
                                    

        metapass="xxxxxxxxxxxx"         
 
        /*metaprotocol=bridge*/ 

        metarepository=Foundation;  

data users_grps;
   length uri name group groupuri $256 id $20;
 
       /* Initialize variables to missing. */
   n=1;
   uri='';
   name='';
   group='';
   groupuri='';
   id='';
 
       /* 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);

  /* 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 'No groups' and output the name. */
      if grpassn in (-3,-4) then do;
         group="No groups";
         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. */
      else do while (grpassn > 0);
         rc2=metadata_getattr(groupuri, "Name", group);
         a+1;
         output;
         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 group;
run;

 

This only gives me details of the group to which the user is a member of.

 

 

Regards,

S

1 ACCEPTED SOLUTION

Accepted Solutions
PaulHomes
Rhodochrosite | Level 12

You could enhance that code by pulling out the email(s) for the user, but personally I would suggest you just reuse code already provided by SAS and use the supplied SAS %MDUEXTR macro.  You point that macro at a library and it will extract user email, phone, location, and group/role membership info (and more) from metadata into Canonical Tables in that library. If the info you need is all in those tables it is much easier than having to get to grips with the SAS Metadata API and the SAS Metadata Model. I would only suggest writing metadata API code if you need something that is not already in those canonical tables.

View solution in original post

1 REPLY 1
PaulHomes
Rhodochrosite | Level 12

You could enhance that code by pulling out the email(s) for the user, but personally I would suggest you just reuse code already provided by SAS and use the supplied SAS %MDUEXTR macro.  You point that macro at a library and it will extract user email, phone, location, and group/role membership info (and more) from metadata into Canonical Tables in that library. If the info you need is all in those tables it is much easier than having to get to grips with the SAS Metadata API and the SAS Metadata Model. I would only suggest writing metadata API code if you need something that is not already in those canonical tables.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1527 views
  • 2 likes
  • 2 in conversation