Fix issue in NamedPipeServerStream.GetImpersonationUserName() (#37676)
authorCarlos Sanchez Lopez <1175054+carlossanlop@users.noreply.github.com>
Fri, 7 Jun 2019 19:35:43 +0000 (12:35 -0700)
committerJan Kotas <jkotas@microsoft.com>
Sat, 8 Jun 2019 14:14:49 +0000 (07:14 -0700)
Fix for issue where NamedPipeServerStream.GetImpersonationUserName() throws unexpected InvalidationOperationException("The operation completed successfully") when impersonation is not allowed, when in fact it should simply return an empty string.

The fix will call GetNamedPipeHandleStateW once. If it fails, it will try to load sspicli.dll if it was not loaded, and will reattempt the call to GetNamedPipeHandleStateW.

This fix is only for Win32: UAP does not allow calling LoadLibraryEx, and Windows Nano says denies access to GetNamedPipeHandleStateW even after attempting to load sspicli.dll.

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.LoadLibraryEx.cs

index 4eef585..bb69e2f 100644 (file)
@@ -11,6 +11,7 @@ internal partial class Interop
     internal partial class Kernel32
     {
         internal const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
+        internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
 
         [DllImport(Libraries.Kernel32, EntryPoint = "LoadLibraryExW", CharSet = CharSet.Unicode, SetLastError = true)]
         internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags);