[C#]解决多语言操作系统找不到everyone NTAccount问题
2012-11-26 11:13
288 查看
NTAccount acct = new NTAccount("Everyone"); FileSystemAccessRule allowRule = new FileSystemAccessRule(acct, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow);
这两行代码运行在英文系统下一切正常,但如果在多语言(如葡萄牙、瑞典、芬兰)系统下则会引发异常,异常信息如:
The conversion of some or all identifying references has failed或
Some or all identity references could not be translated.
也就是在多语言系统找不到对应的“Everyone” NTAccount,那问题自然就转移到如何才能在多语言系统找到匹配的“everyone”呢?这得感谢该帖子:http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/0737f978-a998-453d-9a6a-c348285d7ea3/
直接找到答案了,代码调整如下:
SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null); NTAccount acct = sid.Translate(typeof(NTAccount)) as NTAccount; FileSystemAccessRule allowRule = new FileSystemAccessRule(acct, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow);
WellKnownSidType.WorldSid的Summary是:Indicates a SID that matches everyone.
相关文章推荐
- C# 解决读取dbf文件,提示Microsoft Jet 数据库引擎找不到对象的问题
- c#字符串转datatime时,因操作系统不一致产生的问题解决方法
- C#调用非托管DLL时遇到“找不到指定的模块”问题解决方法
- C#.NET验证码智能识别学习笔记---06 解决java jre问题:JTessBoxEditor.jar打开的时报找不到或无法加载主类 com.sun.tools.javac.Main错误
- 解决arduino IDE闪退的问题(不用修改操作系统语言)
- C#调用exe解决PDF转图片问题(使用PDFBox方案,java语言编译jar包实现)
- 两个小问题解决记录:XCode中多Target时CFBundleDisplayName的多语言本地化;用C++写socket程序时编译错误说read和write找不到
- C#执行批处理,当批处理不在程序根目录时,出现“找不到文件”的问题的解决方法
- C#开发中提示无法加载DLL"***.dll":找不到指定的模块(异常来自HRESULT:0x8007007E)问题的解决办法
- ABP Asp.net(c#) 找不到组件问题的解决
- 如何解决Linux操作系统找不到网卡的问题
- 有关c#.net“无法加载 CSOpenGLC.dll:找不到指定的模块”的问题解决办法
- 支付宝C# RSA签名 报系统找不到指定的文件问题解决
- 解决安装IIS时提示找不到zClientm.exe文件的问题
- GridView中使用类似于Button btnToped = (Button)e.Row.FindControl("btnToped");提示“未将对象引用到实例”,也就是找不到控件的问题的解决方法
- iOS随笔记-开发中遇到的#import头文件找不到的问题解决办法
- 解决此word打开时提示:文档有宏 该应用程序的宏语言支持功能被取消 问题
- qt编译不识别tslib报找不到问题的解决
- C#解决从含身份证号码的Excel表格导入数据库的问题
- VS2005(c#)项目调试问题解决方案集锦