Hello everyone

Recently encountered a situation
Because I have a service set up on IIS of windows Then the service recently needs to add the ability to access the network hard disk service
I found out
 
If you mount the network hard drive directly on the computer Then django of IIS to access Is not found at all
 
Actually it's reasonable to think about it Because the users are different
 

## IIS role and UNC virtual folder problem direction

 
For example: the network hard disk my user is the administrator
But the role of IIS is usually IIS_IUSRS To directly access the mounted network hard drive will indeed cause problems
 
Usually this situation can refer to this:
 

### The trust level of access to the shared directory (UNC) in the IIS site/virtual directory and the established application

 
But the situation I encountered today is I can’t access the network hard drive to add an account He gave an administrator account password at the beginning
 
This is embarrassing
 

 

But I still try to add UNC folder and permissions
Just use the administrator account
And confirmed that the UNC virtual folder is indeed working

 

 

But~
I found that I still can't catch it in python...
I couldn't figure out what the problem was for a while
So I had to look for other directions

 

## Python command mount

 

Then I continued to crawl
Found that there is another solution
Just call the command line directly in python to mount the hard disk
Refer to the following 2 articles

 
 
The following is an example
 
import subprocess
 
winCMD = 'NET USE ' + settings.DOWNLOAD_DIR + ' /User:' + settings.DOWNLOAD_DIR_USERNAME + ' ' + settings.DOWNLOAD_DIR_PASSWORD
subprocess.Popen(winCMD, shell=True)
 

In the program, you can first check whether the folder can be caught
If it doesn't work, execute this command

Then the access path directly uses the path of the network neighbors
E.g:

\\10.58.100.123\myDir\
 
 

The problem should be solved
For your reference
grateful