[英]Get specific user permissions on Azure Data Lake Gen2 (ACL)
I am working with Azure Functions, and I would like to know how I can see the permissions of a user for a certain directory or file.我正在使用 Azure 函数,我想知道如何查看用户对某个目录或文件的权限。
To get the info of ACL I am following the next documentation: https://docs.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-directory-file-acl-python (For the conexion I have used Connect by using an account key option)要获取 ACL 的信息,我正在关注下一个文档: https://docs.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-directory-file-acl-python (对于 conexion我已通过使用帐户密钥选项使用 Connect )
I am able to get the next information:我能够得到下一个信息:
{
'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
}
This returns generic information, but what I would like to know is how can I get permission information for a specific user.这将返回通用信息,但我想知道的是如何获取特定用户的权限信息。 I know how can I get user id or thr user's group id, but not how to relate to ACL.
我知道如何获取用户 ID 或用户组 ID,但不知道如何与 ACL 关联。
Maybe I need to use an API?也许我需要使用 API?
Thanks beforehand!预先感谢!
Based on your result, you haven't given permissions to a user.根据您的结果,您尚未向用户授予权限。
So you need follow this screenshot to give the permissions.因此,您需要按照此屏幕截图授予权限。
Then you could use the code to get its ACL.然后您可以使用该代码获取其 ACL。
acl_props = directory_client.get_access_control()
print(acl_props['acl'])
It should be like this:它应该是这样的:
user::rwx,
user:256xxxx6-019b-479c-a71f-d5axxxx93143:r-x,
group::r-x,
mask::r-x,
other::---
We can find that the second line is the ACL for the user allenwu1.我们可以发现第二行是用户 allenwu1 的 ACL。
Then you could use str.index('user:{user id}:')
to get its position.然后你可以使用
str.index('user:{user id}:')
来获取它的 position。 Then you can get the next three characters, which is the user's ACL.然后就可以得到接下来的三个字符,也就是用户的ACL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.