[英]How can I get the SAS Metadata groups of the current user?
我希望根據當前用戶的元數據組成員身份設置宏變量的值(在工作區服務器的 autoexec 文件中)。
用戶可以在多個組中,我需要能夠編寫邏輯來根據用戶所屬的“最高”組(對於最高的某些定義)來決定變量的值。
我查看了從 SAS 代碼查詢元數據的通用方法,但它們似乎建議執行用戶應該具有管理角色,而我的用戶不會。
用戶不必是管理員即可查詢元數據。 他們將需要對元數據對象具有讀取權限。 我只是我們服務器上的一個用戶,使用http://support.sas.com/kb/30/682.html的改編版,我可以獲得所有用戶及其關聯組的列表:
data users_grps (keep=name group email);
length uri name groupuri group emailuri email $256 ;
call missing(uri, name, groupuri, group, emailuri, email) ;
/* Get URI of first person */
n=1;
nobj=metadata_getnobj("omsobj:Person?@Id contains '.'",n,uri);
if nobj=0 then put 'No Persons available.';
do while (nobj > 0);
call missing(name, groupuri, group, emailuri, email) ;
/* Retrieve the current persons name. */
rc=metadata_getattr(uri, "Name", Name);
/* get the persons email address (only first one)*/
rc2=metadata_getnasn(uri,"EmailAddresses",1,emailURI) ;
rc3=metadata_getattr(emailuri, "Address", email);
/* Get the group association information for the current person. */
a=1;
rcgrp=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 rcgrp 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 (rcgrp > 0);
rc4=metadata_getattr(groupuri, "Name", group);
a+1;
output;
rcgrp=metadata_getnasn(uri,"IdentityGroups",a,groupuri);
end;
/* Get URI of next person. */
n+1;
nobj=metadata_getnobj("omsobj:Person?@Id contains '.'",n,uri);
end;
run;
會認為可以調整以查找當前用戶的組。
此宏將為您提供所有組或特定用戶的直接組成員資格:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.