简体   繁体   English

如何将IIS应用程序池标识用户区域设置为ApplicationPoolIdentity时,如何设置它

[英]How do you set the IIS Application Pool Identity User Locale when it's set to ApplicationPoolIdentity

To clarify the title. 澄清标题。

When you create an application pool in IIS you give it a name. 在IIS中创建应用程序池时,请为其指定名称。 You can then set the identity to ApplicationPoolIdentiy. 然后,您可以将标识设置为ApplicationPoolIdentiy。

Windows then creates this magic user you can't see. Windows然后创建这个你看不到的神奇用户。 Say the app pool name is MyTestAppPool so you would end up with a user called MyTestAppPool (IIS AppPool\\MyTestAppPool) 假设应用程序池名称是MyTestAppPool,那么最终会得到一个名为MyTestAppPool的用户(IIS AppPool \\ MyTestAppPool)

When this happens Windows uses the servers current locale. 发生这种情况时,Windows使用服务器当前区域设置。 Let's say it was US at the time. 让我们说当时是美国。

Then later you change it to UK. 然后你将它改为英国。 While there is a copy this doesn't copy to these magic users I've found. 虽然有副本,但这并没有复制到我发现的这些魔术用户身上。 So your server is set to UK while your MyTestAppPool is set to US. 因此,当您的MyTestAppPool设置为US时,您的服务器将设置为UK。

So when a website runs and you need to say format something to currency in the correct locale you end up with US currency because of the AppPool instead of UK currency. 因此,当一个网站运行并且您需要在正确的区域设置中将某些内容格式化为货币时,由于AppPool而不是英国货币,您最终会使用美国货币。

Is there a way to change the AppPool user's locale? 有没有办法更改AppPool用户的区域设置?

The only way I have found is to delete the app pool and recreate it again after you've set the servers locale to what you want. 我找到的唯一方法是删除应用程序池并在将服务器区域设置设置为所需后再次重新创建它。 What if I don't want to do that. 如果我不想那样做怎么办?

What if I need to have multiple websites running in different locales how would I set the AppPoolIdentity user locale to each of these without having to change the server to what I want before I create the apppool? 如果我需要在不同的语言环境中运行多个网站,如何在不创建apppool之前将AppPoolIdentity用户区域设置为其中每一个而不必将服务器更改为我想要的内容,该怎么办?

When you create and use an App Pool Identity, a "user" is created and there is a folder at C:\\Users\\AppPoolName . 创建和使用应用程序池标识时,将创建“用户”,并在C:\\Users\\AppPoolName有一个文件夹。

In C:\\Windows\\System32\\inetsrv\\config\\applicationHost.config there is an element which on my machine looks like this: C:\\Windows\\System32\\inetsrv\\config\\applicationHost.config有一个元素在我的机器上看起来像这样:

<applicationPoolDefaults managedRuntimeVersion="v4.0">
  <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="false" />
</applicationPoolDefaults>

The combination of these two settings determines the environment (and thus locale) settings that app pool identity runs as. 这两个设置的组合决定了应用程序池标识运行的环境(以及区域设置)设置。

You should be able to figure out the unique Id by checking in HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\hivelist for the user that loads the ..\\Users\\AppPoolName\\NTUSER.DAT and then match it up with the settings in HKEY_USERS\\UnqiueId\\ControlPanel\\International\\Locale settings. 你应该能够通过检查加载..\\Users\\AppPoolName\\NTUSER.DAT的用户的HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\hivelist来找出唯一的ID,然后将其与HKEY_USERS\\UnqiueId\\ControlPanel\\International\\Locale的设置HKEY_USERS\\UnqiueId\\ControlPanel\\International\\Locale设置。

It may just be simpler to set setProfileEnvironment="false" unless you need the settings. 除非您需要设置,否则设置setProfileEnvironment="false"可能更简单。

You can set the culture of your application via web.config or on page level. 您可以通过web.config或页面级别设置应用程序的文化。 This should override the application pool user's culture. 这应该覆盖应用程序池用户的文化。

have a look at this https://msdn.microsoft.com/en-us/library/bz9tc508(v=vs.140).aspx 看看这个https://msdn.microsoft.com/en-us/library/bz9tc508(v=vs.140).aspx

Your web site shouldn't rely on Server setup to work as intended for the locale. 您的网站不应该依赖服务器设置来按照区域设置的方式工作。 You should set the Thread.Culture and Thread.UICulture in your Global.asax file or in the web.config. 您应该在Global.asax文件或web.config中设置Thread.CultureThread.UICulture

If you do it in your project, you protect yourself from Environment issues. 如果您在项目中执行此操作,则可以保护自己免受环境问题的影响。

Doing it this way will also be easier to use different locales in different sites. 这样做也会更容易在不同的站点中使用不同的区域设置。

The best way to solve this is too create your own user account, assign this user to the application pool. 解决此问题的最佳方法是创建自己的用户帐户,将此用户分配给应用程序池。 You can then change this users locale by logging in as the user. 然后,您可以通过以用户身份登录来更改此用户区域设置。

Make sure that this user has access to the web files 确保此用户可以访问Web文件

Have a look at this link 看看这个链接

https://www.bluevalleytech.com/techtalk/blog/assigning-ntfs-folder-permission-to-iis7-application-pools.aspx https://www.bluevalleytech.com/techtalk/blog/assigning-ntfs-folder-permission-to-iis7-application-pools.aspx

You can programmatically change culture of your app by setting this in your Global.asax: 您可以通过在Global.asax中设置此项来以编程方式更改应用程序的文化:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture;
}

where CultureInfo.CurrentCulture will return your OS culture. CultureInfo.CurrentCulture将返回您的操作系统文化。

More info about this you can find in https://support.microsoft.com/pl-pl/kb/306162 , detect os language from c# . 有关这方面的更多信息, 请访问https://support.microsoft.com/pl-pl/kb/306162从c#中检测os语言

You don't want to use CultureInfo.CurrentCulture (this returns culture of current thread) but instead use CultureInfo.InstalledUICulture 您不想使用CultureInfo.CurrentCulture(这会返回当前线程的文化),而是使用CultureInfo.InstalledUICulture

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    Thread.CurrentThread.CurrentCulture = CultureInfo.InstalledUICulture;
    //sets the thread culture to OS language.
}

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

相关问题 在IIS 7中以编程方式为自定义身份应用程序池设置用户帐户 - Programmatically set up user account for custom identity application pool in IIS 7 如何正确设置IIS 7应用程序池标识? - How to set up IIS 7 application pool identity correctly? 如何在IIS 8上以编程方式设置应用程序池标识 - How to programmatically set App Pool Identity on IIS 8 如何手动设置登录的身份用户? - How do you manually set a logged in Identity User? 设置应用程序池iis express 7.5用于应用程序 - Set application pool iis express 7.5 for application 当我更改 IIS 应用程序池身份用户使用自定义帐户时,它会停止应用程序池,即使我再次启动它也是如此 - When I Change the IIS Application Pool Identity User Use Custom Account it stops the Application pool even if I start it again 如何在 web 配置中设置我的网站 iis 应用程序池设置? - How set my website iis application pool setting in web config? ServerManager,正在创建应用程序池,未设置身份 - ServerManager, Creating application pool, identity not set 使用网络身份验证时使用Windows服务/ ApplicationPoolIdentity进行Windows身份验证? - Windows Authentication with Network Service/ ApplicationPoolIdentity when is user Identity used? 以编程方式将应用程序池标识设置为域用户 - Programmatically set App Pool identity to Domain user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM