CORE
mm_getgroups.sas
Go to the documentation of this file.
1 
23 %macro mm_getGroups(
24  user=
25  ,outds=work.mm_getGroups
26  ,mDebug=0
27  );
28 
29 %local mD;
30 %if &mDebug=1 %then %let mD=;
31 %else %let mD=%str(*);
32 %&mD.put Executing mm_getGroups.sas;
33 %&mD.put _local_;
34 
35 %if %length(&user)=0 %then %do;
36  data &outds (keep=groupuri groupname groupdesc);
37  length groupuri groupname groupdesc group_or_role $256;
38  call missing(of _all_);
39  i+1;
40  do while
41  (metadata_getnobj("omsobj:IdentityGroup?@Id contains '.'",i,groupuri)>0);
42  rc=metadata_getattr(groupuri, "Name", groupname);
43  rc=metadata_getattr(groupuri, "Desc", groupdesc);
44  rc=metadata_getattr(groupuri,"PublicType",group_or_role);
45  if Group_or_Role = 'UserGroup' then output;
46  i+1;
47  end;
48  run;
49 %end;
50 %else %do;
51  data &outds (keep=groupuri groupname groupdesc);
52  length uri groupuri groupname groupdesc $256;
53  call missing(of _all_);
54  rc=metadata_getnobj("omsobj:Person?@Name='&user'",1,uri);
55  if rc<=0 then do;
56  putlog "WARNING: rc=" rc "&user not found "
57  ", or there was an error reading the repository.";
58  stop;
59  end;
60  a=1;
61  grpassn=metadata_getnasn(uri,"IdentityGroups",a,groupuri);
62  if grpassn in (-3,-4) then do;
63  putlog "WARNING: No groups found for ";
64  output;
65  end;
66  else do while (grpassn > 0);
67  rc=metadata_getattr(groupuri, "Name", groupname);
68  rc=metadata_getattr(groupuri, "Desc", groupdesc);
69  a+1;
70  output;
71  grpassn=metadata_getnasn(uri,"IdentityGroups",a,groupuri);
72  end;
73  run;
74 %end;
75 
76 %mend;