任何 SAS METADATA_GET* 函数都可以提供有关授权的信息吗
我们在带有元数据服务器的客户端服务器设置中使用 SAS。 我使用 SAS 读取元数据的函数 从元数据中读取 SAS 库、表、文件夹等的属性和关系。
为了验证我们的设置,我们希望列出谁可以访问什么内容,即以编程方式检索您可以在 SAS Management Console 中对象属性的“授权”选项卡上找到的内容:
有人知道在哪里可以找到该信息吗?
为您提供灵感:我通常使用函数在数据步骤中读取元数据,但这次,我使用 Lua
proc Lua restart;
submit;
debug = true
maxDo = 9
function getObjAttr(uri, attrList, old_obj)
new_obj = old_obj or {}
if debug then new_obj.uri = uri:gsub("%s+$", "") end
-- list only the requested attributes
local val_256 = string.rep("v",256)
for _, attrName in ipairs(attrList) do
if sas.METADATA_GETATTR(uri, attrName, val_256) >= 0 then
new_obj[attrName] =
( attrName:sub(1, 2) == 'Is'
or attrName == 'NumRows'
or attrName == 'UsageVersion' ) and tonumber(val_256)
or val_256:gsub("%s+$", ""):gsub("^%s+", "")
end
end
-- list all properties
local prop_256 = string.rep("p",256)
for prop_nr = 1, maxDo do
if sas.METADATA_GETNPRP(uri, prop_nr, prop_256, val_256) < 0 then break end
new_obj["_".. prop_256:gsub("%s+$", "")] = val_256:gsub("%s+$", "")
end
return new_obj
end
-- find the path to an object
function getLocation(uri)
local folder_256 = string.rep("f",256)
if sas.METADATA_GETNASN(uri,
string.find(uri, ":Tree") and 'ParentTree' or 'Trees',
1, folder_256) >= 0
then
return getObjAttr(folder_256, {'name'}, {location = getLocation(folder_256)})
end
end
-- collect all libraries
lib_set = {}
for obj_nr = 1, maxDo do
local uri_256 = string.rep("u",256)
-- test with a limited set
if sas.METADATA_GETNOBJ("SASLibrary?@name contains '_CBC'", obj_nr, uri_256) < 0 then break end
-- to get all, change to SASLibrary?@id contains '.'
lib_set[uri_256:gsub("%s+$", ""):gsub(".+%.", "")] =
getObjAttr(uri_256, {'name', 'libref', 'engine'}, {location = getLocation(uri_256)})
end
if debug then print("Lua: ".. table.tostring(lib_set)) end
-- to be completed with code to export the relevant info to sas datasets
endsubmit;
run;
We use SAS in a client server setup with a metadata server.
I use SAS Functions for Reading Metadata
to read attributes and relations of SAS libraries, tables, folders etc from the metadata.
To verify our setup, we would like to list who can access what, i.e. to programmatically retrieve what you can find in SAS Management Console on the Authorization tab of an object's properties:
Does anyone know where to find that information?
For your inspiration: I usually use the functions to read metadata in a datastep, but this time, I used Lua
proc Lua restart;
submit;
debug = true
maxDo = 9
function getObjAttr(uri, attrList, old_obj)
new_obj = old_obj or {}
if debug then new_obj.uri = uri:gsub("%s+quot;, "") end
-- list only the requested attributes
local val_256 = string.rep("v",256)
for _, attrName in ipairs(attrList) do
if sas.METADATA_GETATTR(uri, attrName, val_256) >= 0 then
new_obj[attrName] =
( attrName:sub(1, 2) == 'Is'
or attrName == 'NumRows'
or attrName == 'UsageVersion' ) and tonumber(val_256)
or val_256:gsub("%s+quot;, ""):gsub("^%s+", "")
end
end
-- list all properties
local prop_256 = string.rep("p",256)
for prop_nr = 1, maxDo do
if sas.METADATA_GETNPRP(uri, prop_nr, prop_256, val_256) < 0 then break end
new_obj["_".. prop_256:gsub("%s+quot;, "")] = val_256:gsub("%s+quot;, "")
end
return new_obj
end
-- find the path to an object
function getLocation(uri)
local folder_256 = string.rep("f",256)
if sas.METADATA_GETNASN(uri,
string.find(uri, ":Tree") and 'ParentTree' or 'Trees',
1, folder_256) >= 0
then
return getObjAttr(folder_256, {'name'}, {location = getLocation(folder_256)})
end
end
-- collect all libraries
lib_set = {}
for obj_nr = 1, maxDo do
local uri_256 = string.rep("u",256)
-- test with a limited set
if sas.METADATA_GETNOBJ("SASLibrary?@name contains '_CBC'", obj_nr, uri_256) < 0 then break end
-- to get all, change to SASLibrary?@id contains '.'
lib_set[uri_256:gsub("%s+quot;, ""):gsub(".+%.", "")] =
getObjAttr(uri_256, {'name', 'libref', 'engine'}, {location = getLocation(uri_256)})
end
if debug then print("Lua: ".. table.tostring(lib_set)) end
-- to be completed with code to export the relevant info to sas datasets
endsubmit;
run;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这在纯粹的宏观上是不可能的。但是 - 它可以使用批处理工具来完成。
我开始向 core 库发起 PR,该库将利用这些库 - 如果您想完成它,做我的客人吧!我们当前的 SAS 9 环境没有 X Command,所以我无法测试它。
https://github.com/sasjs/core/pull/45/files
I don't think this is possible in pure macro. However - it can be done with batch tools.
I started a PR to the core library that would make use of these - if you feel like finishing it off, be my guest! Our current SAS 9 environment does not have X Command so I can't test it.
https://github.com/sasjs/core/pull/45/files