jacqueskang / IpcServiceFramework

.NET Core Inter-process communication framework
MIT License
358 stars 77 forks source link

[Windows] IdentityNotMappedException on host start #154

Closed InfinityGhost closed 4 years ago

InfinityGhost commented 4 years ago

Describe the bug System.Security.Principal.IdentityNotMappedException occurs when starting host on Windows

To Reproduce Steps to reproduce the behavior:

  1. Use latest release of framework (3.0.4)
  2. Create a host NamedPipeIpcEndpoint
  3. Execute it, crashes consistently with this exception
fail: JKang.IpcServiceFramework.Hosting.NamedPipe.NamedPipeIpcEndpoint[0]
Error occurred
System.AggregateException: One or more errors occurred. (Some or all identity references could not be translated.)
---> System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated.
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)
at JKang.IpcServiceFramework.Hosting.NamedPipe.NamedPipeIpcEndpoint`1.WaitAndProcessAsync(Func`3 process, CancellationToken cancellationToken)
--- End of inner exception stack trace ---

Expected behavior Host starts as normal without unhandled exceptions

Additional context I figure this may be caused by user account names or information with non-ascii characters in it, however I can't confirm it for myself. This did not occur on 0.3.2.

Project I'm using it in, if needed to see what maybe I've done wrong: https://github.com/InfinityGhost/OpenTabletDriver

michaelrall commented 4 years ago

Hey, I experience the same problem with the same version. I'm working on Windows 10 (DE), but no users with special characters in their usernames.

michaelrall commented 4 years ago

I guess I found the problem - should be the same as yours. Created a fix and opended a pull request...