Sample 26094: Is _MetaPerson a Member of a particuliar Group
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Determine if _MetaPerson is a member of specified group. Can be used in Stored Process, or Standalone SAS session. Standalone Session requires setting the value of _MetaPerson macro variable and the required Metadata system options. Set macro variable groupname to value of group in question.
/* _MetaPerson_isamember_of_group.sas */
/* Find if a user is a member of a particuliar group */
/* Code uses Metadata_Resolve data step function to detemine group membership */
/* Author BT 19SEP2006 */
/* Set Metadata system options if needed */
/*
options metauser="userid" metapass="pass" metarepository="Foundation"
metaserver="serverip" metaport=8561;
*/
/* uncomment and set _MetaPerson value if needed */
/* %let _MetaPerson=SAS Demo User; */ /* No need to set this for a Stored Process */
%let groupname=Oragroup; /* Name of group to check membership */
data _null_;
length obj type $256 id $20;
getperson=symget('_metaperson');
getgroup=symget('groupname');
type="";
id="";
/* Build URI for the group with a name of & groupname, and that a &_MetaPerson is a member */
obj="omsobj:IdentityGroup?IdentityGroup[@Name='"||"&groupname"
||"'][MemberIdentities/Person[@Name='"||"&_METAPERSON"||"']]";
*put obj=;
rc=metadata_resolve(obj,type,id);
*put rc=; /* This should be 1 if person is member of group */
if (rc) then do;
*put type= id=;
call symput('isamember','1');
Call symput('Isamemberc','Yes');
put "Is &_metaperson a member of Group &groupname..? Yes. " rc=;
end;
else do;
call symput('isamember','0');
Call symput('Isamemberc','No');
put "&_MetaPerson is a not member of Group &groupname.. " rc=;
end;
run;
%put "Is &_MetaPerson a member of group &groupname.?" "&Isamemberc";
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Is SAS Demo User a member of Group Oragroup? Yes. rc=1
334
335 %put "&_MetaPerson a member of group &groupname.?" "&Isamemberc";
"SAS Demo User a member of group Oragroup?" "Yes"
Stored Processes may need to determine if the current user is a member of a group. This sample uses Metadata data step functions to provides that functionality. Can be used outside of Stored Processes by manually setting the macro variable _MetaPerson
Date Modified: | 2006-09-21 03:03:04 |
Date Created: | 2006-09-19 10:02:58 |
Operating System and Release Information
SAS System | SAS Integration Technologies | All | 9.1 TS1M3 | n/a |