I am trying to get file attributes in python using win32api GetFileAttributes
method and getting error access is denied.
(5, 'GetFileAttributes', 'Access is denied.')
MSDN documentation doesn't contain an error section for GetFileAttributes
.
Join Stack Overflow to learn, share knowledge, and build your career.
I am trying to get file attributes in python using win32api GetFileAttributes
method and getting error access is denied.
(5, 'GetFileAttributes', 'Access is denied.')
MSDN documentation doesn't contain an error section for GetFileAttributes
.
When the GetFileAttributes function is called, the kernel actualy attempts to open the file with FILE_READ_ATTRIBUTES access right. So, if the security descriptor of the file does not grant you that right, you get the access denied error (if some other conditions are not met).
Being an admin/system user on Windows is not the same as being root on Linux. You can do what you want but you need to do some extra work for it. The security model is stil in effect. However, as an administrator (or a higher privileged user) you can use features of the model to get access to everywhere
For example, obtain privileges (SE_BACKUP_NAME, SE_RESTORE_NAME) to act as a backup/restore application which provides you with nearly unlimited access to file system and the registry. Or, you can change security descriptor of the file to grant you necessary access rights (you can do this as a member of the Administrators group, although the integrity levels may impose a problem here – I am not sure of this now).
If you have a directory-listing access to the parent directory, you may try to obtain necessary information about the target file by a directory listing. File attributes are included in the data.