获取 Azure Data Lake Gen2 上的特定用户权限 (ACL)

问题描述 投票:0回答:1

我正在使用 Azure Functions,我想知道如何查看用户对某个目录或文件的权限。

为了获得ACL的信息,我按照下面的文档进行操作。https:/docs.microsoft.comen-usazurestorageblobsdata-lake-storage-directory-file-acl-python。 (我用的conexion是 使用账户密钥进行连接 选项)

我能够得到下一个信息。

{
    'accept_ranges': None,
    'cache_control': None,
    'content_disposition': None,
    'content_encoding': None,
    'content_language': None,
    'content_length': None,
    'content_range': None,
    'content_type': None,
    'content_md5': None,
    'date': datetime.datetime(XXXXX),
    'etag': '"4545454545"',
    'last_modified': datetime.datetime(XXXXX),
    'request_id': 'XXXXX',
    'version': '2019-02-02',
    'resource_type': None,
    'properties': None,
    'owner': '123',
    'group': '123',
    'permissions': 'rwxr-x---',
    'acl': 'user: : rwx,
    group: : r-x,
    other: : ---',
    'lease_duration': None,
    'lease_state': None,
    'lease_status': None,
    'error_code': None
}

但我想知道的是 我如何才能获得特定用户的权限信息。我知道如何获得用户ID或用户组ID,但不知道如何与ACL相关联。

也许我需要使用一个API?

事先谢谢你!

azure azure-functions azure-data-lake
1个回答
1
投票

根据你的结果,你没有给用户权限。

所以你需要按照这个截图来给用户权限。

enter image description here

然后你就可以使用代码来获取它的ACL。

acl_props = directory_client.get_access_control()

print(acl_props['acl'])

应该是这样的。

user::rwx,
user:256xxxx6-019b-479c-a71f-d5axxxx93143:r-x,
group::r-x,
mask::r-x,
other::---

我们可以发现第二行是allenwu1用户的ACL。

然后你可以使用 str.index('user:{user id}:') 来获得它的位置。然后就可以得到接下来的三个字符,也就是用户的ACL。

© www.soinside.com 2019 - 2024. All rights reserved.