1

我正在使用 IOM 连接到元数据服务器的配置中工作 - 因此我的环境中没有自动宏变量来确定用户 ID(我们正在使用具有通用主机帐户的池工作区服务器)。

是否有一小段代码可用于查询元数据服务器以获取 SAS 用户 ID?

4

1 回答 1

1

以下内容相当冗长,可能会缩短 - 但它确实有效!

data _null_;
call symput('login_id',''); /* initialise to missing */
n = 1;
length loginUri person $ 512;
nobj = metadata_getnobj("omsobj:Login?*",n, loginUri);
if (nobj>0) then do;
    length __uri __objName __porig personUri $256;
    __porig = loginUri;
    __uri = '';
    __objName = '';
    __n = 1;
    __objectFound = 0;
    personUri = "";
    __numObjs = metadata_getnasn(__porig ,"AssociatedIdentity", 1, __uri);
    do until(__n > __numObjs | __objectFound );
        __rc = metadata_getattr(__uri, "PublicType", __objName);
        if __objName="User" then do;
            __rc=metadata_getattr(__uri, "Name", __objName);
            __objectFound = 1;
            personUri = __uri;
        end;
        else do;
            __n = __n+1;
            rc = metadata_getnasn(__porig, "AssociatedIdentity", __n, __uri);
        end;
    end;
    if upcase("N")="Y" and not __objectFound then do;
        put "*ERROR*: Object with  PublicType=" "User" " not found for parent " loginUri " under AssociatedIdentity association";
        stop;
    end;
    ;
    rc = metadata_getattr(personUri, "Name", person);
    call symput("login_id", trim(person));
end;
run;
%put &login_id;
于 2012-11-19T15:37:48.697 回答