简体   繁体   中英

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

I am currently setting up a django site to run on IIS, however I am running into an issue with the USZipCodes python module, When it goes to call the USZipCodes module if gets an access denied error.

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'

Figured I would follow up. After quite some hours I was able to resolve the issue.

When you setup the IIS, it creates a local group called IIS_LUSRS. You must add the user (local or domain) that you log into to run IIS to this local groups (can be done through the lusrmgr.msc program). Then after this is done, allow that group modify and write privs on the python site package pathlib and the system profile in system 32.

This is not the best solutions, but it fixed it for me...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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