Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NTAccount.Translate Method fails with error Some or all identity references could not be translated

PipeAccessRule par = new PipeAccessRule("Everyone", PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow);

This code fails with error:

Some or all identity references could not be translated.

I guess this is because I'm using "Everyone" while launch my app on non-English local. On English system everything is OK.

How to avoid this? Is there some enum describes general user groups?

Stack trace:

at System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection sourceAccounts, Type targetType, Boolean forceSuccess)    
at System.Security.Principal.NTAccount.Translate(Type targetType)    
at System.Security.AccessControl.CommonObjectSecurity.ModifyAccess(AccessControlModification modification, AccessRule rule, Boolean& modified)    
at System.Security.AccessControl.CommonObjectSecurity.AddAccessRule(AccessRule rule)    
at System.IO.Pipes.PipeSecurity.AddAccessRule(PipeAccessRule rule)    
like image 552
Ksice Avatar asked Feb 20 '23 20:02

Ksice


1 Answers

Solved by using second constructor of PipeAccessRule and SecurityIdentifier instead of string:

System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.BuiltinUsersSid, null);
PipeAccessRule par = new PipeAccessRule(sid, PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow);
like image 63
Ksice Avatar answered Feb 22 '23 11:02

Ksice