Architecting, installing and maintaining your SAS environment

SAS code to add users and groups to a group?

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

SAS code to add users and groups to a group?

Hi

I have a piece of code that lists all the objects (user or a group) that is a a member of another group

/*Connect to the metadata server.  */

options metaserver="biserver.whatever.com"

  metaport=8561

  metauser="sasadm@saspw"

  metapass="password"

  metarepository="Foundation";

%mduextr(libref=work)

proc sql;

  create table work.sasmembership as

  select distinct name 'name' as name , memName 'memName' as memName,'GROUP'

  from work.Groupmemgroups_info

  where substr(name,1,1) in ('p','v','f','w') or name in ('Report Developer','sqlserver','Report Viewer')

  UNION

  select distinct name 'name' as name , memName 'memName' as memName,'USER'

  from work.Groupmempersons_info

  where substr(name,1,1) in ('p','v','f','w') or name in ('Report Developer','sqlserver','Report Viewer');

quit;

what i want now is to be able to go through that group and isue a metadata command to add the member (be it a group or user) to the group

on another server is there a proc metadata command to add a group or user to a group?

ie

command bla addtogroup jeff destinationgroupname

or

command bla addtogroup group1 destinationgroup


Accepted Solutions
Solution
‎08-19-2015 10:32 AM
SAS Employee
Posts: 15

Re: SAS code to add users and groups to a group?

Linus is right, so yes it is doable.

You can use the User Import Macros (of which %mduimplb is the one which does the loading of data from 'canonical' - i.e pre-defined format - tables into metadata), to make users and groups members of a group, even if you're not using it to add/update/delete any users or groups themselves. You will need to populate one of these canonical tables called grpmems, which has two columns: grpkeyid memkeyid. The first, grpkeyid is the ID for the group as it was loaded into metadata - the value depends on how the group was populated. The second column, memkeyid, can be a user keyid, or a group keyid. The User Import Macros are documented here, and the canonical tables illustrated here.



View solution in original post


All Replies
Super User
Posts: 5,431

Re: SAS code to add users and groups to a group?

%mduimplb?

Data never sleeps
Contributor
Posts: 24

Re: SAS code to add users and groups to a group?

that seems to add users and groups to METADATA but it doesn't add users to groups or groups to groups correct?

I have all my users added and all my groups added via %mduimplb  now I need to populate the groups based on a query to an older server

that had all the users added to the groups manually. Is that doable?

Solution
‎08-19-2015 10:32 AM
SAS Employee
Posts: 15

Re: SAS code to add users and groups to a group?

Linus is right, so yes it is doable.

You can use the User Import Macros (of which %mduimplb is the one which does the loading of data from 'canonical' - i.e pre-defined format - tables into metadata), to make users and groups members of a group, even if you're not using it to add/update/delete any users or groups themselves. You will need to populate one of these canonical tables called grpmems, which has two columns: grpkeyid memkeyid. The first, grpkeyid is the ID for the group as it was loaded into metadata - the value depends on how the group was populated. The second column, memkeyid, can be a user keyid, or a group keyid. The User Import Macros are documented here, and the canonical tables illustrated here.



Contributor
Posts: 24

Re: SAS code to add users and groups to a group?

Posted in reply to DavidStern

Ah gotcha that makes sense thanks guys!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1041 views
  • 5 likes
  • 3 in conversation