如何获得内置Windows"网络服务"帐户的本地化版本?

use*_*ame 11 c# windows iis-6

为了设置我的Web应用程序,我需要完全控制'NETWORK SERVICE'帐户的某个文件夹.它工作正常,但在非英语系统上,我得到了System.Security.Principal.IdentityNotMappedException.这是因为此内置帐户的名称已针对该系统进行了本地化(我使用的是带编码的值'NETWORK SERVICE').有没有办法以编程方式找出本地化版本'NETWORK SERVICE'是什么?

Hen*_*use 17

只需使用此代码:

var account = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null).Translate(typeof(NTAccount)).Value;
Run Code Online (Sandbox Code Playgroud)