繁体   English   中英

Unique PermissionError: [WinError 5] 访问被拒绝 IIS 问题

[英]Unique PermissionError: [WinError 5] Access is denied IIS Issue

我目前正在设置一个 django 站点以在 IIS 上运行,但是我遇到了 USZipCodes python 模块的问题,当它调用 USZipCodes 模块时,如果遇到拒绝访问错误。

I have confirmed all folders regarding this EXCEPT the systemprofile folder has proper permissions for the IIS_IUSRS profile. I would do the systemprofile as well but it just give me more errors and I would prefer not to

This module works fine when not IIS, through CMD it works fine, it is only when using IIS to run the app does this occur.

I suspect I may just have the cut the module out but I would prefer not too

Error Log:
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Python310\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\inetpub\wwwroot\Apps\scituateApp\.\tickets\views.py", line 286, in push
    json_client['street_name'], zco(json_client['zip']), json_client['state'], json_client['zip'],
  File "C:\inetpub\wwwroot\Apps\scituateApp\.\tickets\views.py", line 15, in zco
    search = SearchEngine()
  File "C:\Python310\lib\site-packages\uszipcode\search.py", line 153, in __init__
    self._download_db_file_if_not_exists()
  File "C:\Python310\lib\site-packages\uszipcode\search.py", line 173, in _download_db_file_if_not_exists
    download_db_file(
  File "C:\Python310\lib\site-packages\uszipcode\db.py", line 33, in download_db_file
    Path(db_file_path).parent.mkdir(parents=True, exist_ok=True)
  File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 1614, in mkdir
    _try_except_filenotfounderror(_try_func, _exc_func)
  File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 117, in _try_except_filenotfounderror
    try_func()
  File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 1605, in _try_func
    self._accessor.mkdir(self, mode)
  File "C:\Python310\lib\site-packages\pathlib_mate\pathlib2.py", line 593, in wrapped
    return strfunc(str(pathobj), *args)
PermissionError: [WinError 5] Access is denied: 'C:\\Windows\\system32\\config\\systemprofile\\.uszipcode'

以为我会跟进。 几个小时后,我能够解决这个问题。

设置 IIS 时,它会创建一个名为 IIS_LUSRS 的本地组。 您必须将您登录以运行 IIS 的用户(本地或域)添加到此本地组(可以通过 lusrmgr.msc 程序完成)。 然后在完成此操作后,允许该组在 python 站点包 pathlib 和系统 32 中的系统配置文件上修改和写入 privs。

这不是最好的解决方案,但它为我解决了它......

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM