从web.config到IIS应用程序池身份

发布于 2025-01-29 10:09:22 字数 610 浏览 3 评论 0原文

我是IIS/ASP .NET开发的新手,我的应用程序使用的连接字符串已声明为我的Web.config。

现在,我阅读/听到我可以使用IIS应用程序池标识而不是web.config。

这是我所做的:

  • 我已经从我的web.config
  • 设置我的应用程序池标识属性 - > (Identity = ApplicatityPoolIdentity)
  • 在“自定义”(例如source = sql ... blah; onirter catalog = dbname; intemperated security; intection security = false; persist security; ;用户ID = mydBusername; password = myPassword; connect timeout = 60; encrypt = false;当前语言=英语;“

据我所知,但我的问题是,这真的是您如何配置它的吗?

我的印象是您可以使用一些变量(用户名,通行证,dbname..Etc),在您的web.config上声明并通过您的应用程序池身份绑定它,但我找不到任何文章。

谢谢

I'm new to IIS/ASP .Net development, my application is using connection string which are declared to my web.config.

Now I read/heard that I can use IIS App Pool Identities to use instead of web.config.

Here's what I did:

  • I've deleted my connection string from my web.config
  • setup my app pool Identity property -> (Identity = ApplicationPoolIdentity)
  • Added my connection string declared/within the App Site Connection Strings under "Custom" like "Data Source=sql...blah;Initial Catalog=dbname;Integrated Security=False;Persist Security Info=False;User ID=MyDBUserName;Password=MyPassword;Connect Timeout=60;Encrypt=False;Current Language=English;"

It works as far as I know, but my question is, is this really how you configure it?

I was under the impression that you could use some variable (username, pass, dbname..etc), declared it on your web.config and binds it thru your app pool identities but I cannot find any article regarding that.

Thank You

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慈悲佛祖 2025-02-05 10:09:22

您可以设置App-Pool在下面运行的用户。要做的就是让应用程序池认为用户是登录服务器的某些特定用户。

这往往不会影响您的数据库代码,因为您仍然需要告诉代码使用哪种数据库。即使您的主机计算机和网络都使用域控制器表示,并且您使用Windows登录来消耗SQL Server。您的.NET代码将需要一些连接字符串来指定数据库和服务器。您添加了App-Pool下的用户识别(我假设此):

“在此处输入图像说明”

好吧,现在“用户”适用于您的文件和网络权利。因此,该用户可以说仅限于某些文件夹 - 也许是另一台具有大量文档的服务器。

在“自定义”下的应用程序站点连接字符串中添加了我的连接字符串

,并将连接字符串放在Web.config中 - 如果您在上述执行后检查Web配置,则应在Web.config中看到该字符串。

因此,从理论上讲,在您的代码中,您可以连接到数据库服务器 - 将使用您的应用程序用户,但是您仍然有一个连接字符串 - 哪个数据库,什么服务器等。仍然需要定义(和在您的代码中使用)。我的意思是,说具有Windows身份验证的台式机对SQL Server并不能使您失去挂钩,因为在某些地方使用定义的连接字符串。虽然用户可能在“定义” App-pool用户的上下文中运行,但您仍然需要一些位置来存储并最终使用一些连接字符串。因此,定义应用程序中哪个用户池中的代码将运行为?您仍然需要一个连接字符串,并且您使用的连接字符串不会存储,也不会存储,也不会来自App-Pool设置。

You can set the user that the app-pool runs under. All that does is make the app-pool think that the user is some particular user who is logged on to the server.

This tends to NOT effect your database code, since you STILL need to tell your code what database to use. Even if your host computer and network is say using a domain controller, and you using windows logons to consume sql server. Your .net code behind will WILL need some connection string to specify the database and server anyway. And you having added that user under app-pool identify (I assume this one):

enter image description here

Well, now that "user" is for your file and network rights. So, that user can say be restricted to some set of folders - maybe a another server with large number of documents.

Added my connection string declared/within the App Site Connection Strings under "Custom"

Yes, and that puts the connection string in web.config - if you check the web config after doing above, you should see that string in web.config.

So, in theory, in your code, you can connect to the database server - and your app-pool user will be used, but you STILL have a connection string - what database, what server, etc. still needs to be defined (and used in your code). I mean, say desktop with windows authentication to SQL server does not get you off the hook as having a defined connection string some place to use. While the user might be running in the context of the "defined" app-pool user, you still need some place to store and eventually use some connection string. So, the fact of defining what user in app pool the code behind will run as? You still need a connection string and the connection string you use to the database would not be stored, nor come from app-pool settings anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文