2017-05-17 13 views
0

現在のユーザーのメタデータグループメンバシップに基づいて(ワークスペースサーバーのautoexecファイル内の)マクロ変数の値を設定したいとします。現在のユーザのSASメタデータグループを取得するにはどうすればよいですか?

ユーザーは複数のグループに属している可能性があり、ユーザーがメンバーである「最高の」グループに基づいて変数の値を決定するロジックを書く必要があります。

私はSASコードからメタデータを照会するための一般的な方法を検討しましたが、実行ユーザーに管理役割が必要であり、ユーザーがそうでないことを示唆しているようです。

答えて

1

ユーザーはメタデータを照会するために管理者である必要はありません。彼らは、メタデータオブジェクトへの読み取りアクセス権を持っている必要があります。私は、当社のサーバー上のユーザーだけだ、と私は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:[email protected] 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:[email protected] contains '.'",n,uri); 
    end; 

run; 

はそれがのグループをルックアップするために適合させることができると思うだろう現在の使用者。

関連する問題