[英]How to get localized version of built-in windows 'Network Service' account?
In order to setup my web application I need to give a full control to a certain folder for a 'NETWORK SERVICE'
account. 为了设置我的Web应用程序,我需要完全控制
'NETWORK SERVICE'
帐户的某个文件夹。 It works fine, but on a non English systems I'm getting System.Security.Principal.IdentityNotMappedException
. 它工作正常,但在非英语系统上我得到
System.Security.Principal.IdentityNotMappedException
。 This is because the name of this built-in account is localized for that system (I'm using harcoded value 'NETWORK SERVICE'
). 这是因为此内置帐户的名称已针对该系统进行了本地化(我使用了带编码的值
'NETWORK SERVICE'
)。 Is there a way to find out programmatically what the localized version of 'NETWORK SERVICE'
is? 有没有办法以编程方式找出
'NETWORK SERVICE'
的本地化版本是什么?
只需使用此代码:
var account = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null).Translate(typeof(NTAccount)).Value;
I guess you can p/invoke LookupAccountSid() , since it returns the localized account name . 我猜你可以调用LookupAccountSid() ,因为它返回本地化的帐户名 。 The SID of
Network Service
is S-1-5-20
. Network Service
的SID是S-1-5-20
。
You can find the method signature and an invocation example here . 您可以在此处找到方法签名和调用示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.