IIS教程:因權限問題被拒絕訪問的解決方案


https://blog.csdn.net/a497785609/article/details/49952281

寫了一個類IISAdmin,負責建立、設置、刪除虛擬目錄,發現在web中調用,遇到權限問題,解決方法如下(轉載):

 下面代碼在ASP.NET中,會因權限問題被拒絕訪問。 

 

以下為引用的內容:
System.DirectoryServices.DirectoryEntry directoryEntry; 
directoryEntry = new System.DirectoryServices.DirectoryEntry("IIS://localhost/w3svc/1"); 
directoryEntry.Invoke("Start", new object[] { }); 錯誤:拒絕訪問。 
異常詳細信息: System.UnauthorizedAccessException: 拒絕訪問。 解決方法 
修改web.config文件 
<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
       <identity impersonate="true" userName="administrator" password="1q2w3e4r"/> 
    </system.web> 
</configuration>

 

 在ASP.NET里面使用COM對象的時候,會被拒絕訪問。

 可以在web.config里面添加下面代碼解決

 

以下為引用的內容:
<identity impersonate="true" userName="username" password="password"/>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM