简体   繁体   English

如何在ASP.NET应用程序中设置身份验证

[英]How to set the authentication in asp.net application

We have to manipulate the iis in our application,and we meet the Access denied error. 我们必须在应用程序中操作iis,并且遇到Access denied错误。

Then we add this to the web.config: 然后,将其添加到web.config中:

<identity userName="username" password="pass" impersonate="true"/>

It works,we can manipulate the iis(create virtual application and etc..). 它可以正常工作,我们可以操纵iis(创建虚拟应用程序等)。

However we have to access the shared folders in the application too,after add the above line,we can only access the shared folders on the machine which server our application. 但是我们也必须访问应用程序中的共享文件夹,添加以上行之后,我们只能访问应用程序所在服务器的计算机上的共享文件夹。

If I remove the line from the web.config,we can access the shared folders from other servers. 如果我从web.config中删除该行,我们可以从其他服务器访问共享文件夹。

So it seems that we can not manipulate the iis and access the shared folders at the same time. 因此,似乎我们无法操纵iis并同时访问共享文件夹。

How to fix it? 如何解决?

Give access to shared folders to the user that you have specified in the identity line in web.config because your web application is using those credentials to access the shared folders and it will only be possible if user specified there has access. 将共享文件夹的访问权限授予您在web.config的标识行中指定的用户,因为您的Web应用程序正在使用这些凭据来访问共享文件夹,并且只有在其中指定的用户有权访问的情况下,才有可能。

Or you can switch to windows authentication see How To: Use Windows Authentication in ASP.NET 2.0 或者可以切换到Windows身份验证,请参见如何:在ASP.NET 2.0中使用Windows身份验证。

There is another alternative to achieve the same. 还有另一种方法可以达到相同目的。

Go to iis and set your application pool identity to user which has permissions to folder. 转到iis,并将您的应用程序池标识设置为对文件夹具有权限的用户。

hope it will resolve your issue. 希望它能解决您的问题。

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

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