| 1 | DATA _null_; |
| 2 | |
| 3 | LENGTH type1 type2 id1 id2 src_uri dest_uri mem_uri mem_name $ 50; |
| 4 | call missing (of _character_); |
| 5 | |
| 6 | |
| 7 | src_obj="omsobj:IdentityGroup? @Name=&source_group_name"; |
| 8 | dest_obj="omsobj:IdentityGroup? @Name=&dest_group_name"; |
| 9 | |
| 10 | |
| 11 | rc1=metadata_resolve(src_obj,type1,id1); |
| 12 | src_uri=cats(type1,'\',id1); |
| 13 | if rc1 < 1 then do; /* If unable to locate, notify and stop. */ |
| 14 | put "ERROR: SOURCE group &source_group_name not found in Metadata."; |
| 15 | stop; |
| 16 | end; |
| 17 | |
| 18 | /* Test for the existence of the destination group. */ |
| 19 | rc2=metadata_resolve(dest_obj,type2,id2); |
| 20 | dest_uri=cats(type2,'\',id2); |
| 21 | |
| 22 | if rc2 < 1 then do; /* If unable to locate, notify and stop. */ |
| 23 | put "ERROR: Destination group &dest_group_name not found in Metadata."; |
| 24 | stop; |
| 25 | end; |
| 26 | |
| 27 | /* Count the number of members in the source group. */ |
| 28 | mem_count=metadata_getnasn(src_uri,"MemberIdentities",1,mem_uri); |
| 29 | put "NOTE: SOURCE group &source_group_name has " mem_count "members."; |
| 30 | |
| 31 | /* For each member in the source group, */ |
| 32 | /* add the member to the destination group. */ |
| 33 | |
| 34 | do n=1 to mem_count; |
| 35 | rc=metadata_getnasn(src_uri,"MemberIdentities",n,mem_uri); |
| 36 | rc=metadata_getattr(mem_uri,"Name",mem_name); |
| 37 | put "NOTE: Adding " mem_name "to destination group &dest_group_name"; |
| 38 | rc=metadata_setassn(dest_uri,"MemberIdentities","APPEND",mem_uri); |
| 39 | put mem_uri; |
| 40 | END; |
| 41 | RUN; |