Skip to content

Commit

Permalink
Switch conditional symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson-tomo committed Apr 7, 2024
1 parent a0a1650 commit 4f77005
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/NLog.WindowsIdentity/ImpersonatingTargetWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ internal sealed class NewIdentityHandle : IDisposable
public string Domain { get; }
public int Password { get; }

#if NET35 || NET45 || NET46
#if NETFRAMEWORK
public WindowsIdentity Handle { get; }
private readonly IntPtr _handle = IntPtr.Zero;
#else
Expand All @@ -264,7 +264,7 @@ public NewIdentityHandle(string userName, string domain, string password, Securi
throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());
}

#if NET35 || NET45 || NET46
#if NETFRAMEWORK
// adapted from:
// https://www.codeproject.com/csharp/cpimpersonation1.asp
if (!NativeMethods.DuplicateToken(logonHandle, (int)impersonationLevel, out _handle))
Expand All @@ -290,7 +290,7 @@ public bool IsValid(string userName, string domain, string password)
public void Close()
{
Handle.Dispose();
#if NET35 || NET45 || NET46
#if NETFRAMEWORK
if (_handle != IntPtr.Zero)
NativeMethods.CloseHandle(_handle);
#endif
Expand All @@ -303,7 +303,7 @@ public void Dispose()

internal static void RunImpersonated<T>(NewIdentityHandle newIdentity, Action<T> executeOperation, T state)
{
#if NET35 || NET45 || NET46
#if NETFRAMEWORK
WindowsImpersonationContext context = null;
try
{
Expand Down
2 changes: 1 addition & 1 deletion src/NLog.WindowsIdentity/NLog.WindowsIdentity.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' ">net46;net45;net35;netstandard1.5;netstandard2.0;net6.0-Windows</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetFrameworks)' == '' ">net46;net45;net35;netstandard1.5;netstandard2.0;net6.0-windows</TargetFrameworks>
<RootNamespace>NLog</RootNamespace>

<VersionPrefix>5.3.0</VersionPrefix>
Expand Down
2 changes: 1 addition & 1 deletion src/NLog.WindowsIdentity/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace NLog.Internal

internal static class NativeMethods
{
#if !NET35 && !NET45 && !NET46
#if !NETFRAMEWORK
// obtains user token
[DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
#if !NET35
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ImpersonatingTargetWrapperTests()
LogManager.ThrowExceptions = true;
}

#if NET35 || NET45 || NET46
#if NETFRAMEWORK
[Fact(Skip = "CreateUserIfNotPresent fails with NetCore")]
#else
[Fact]
Expand Down Expand Up @@ -100,7 +100,7 @@ public void ImpersonatingWrapperTest()
logFactory.Shutdown();
}

#if NET35 || NET45 || NET46
#if NETFRAMEWORK
[Fact(Skip = "CreateUserIfNotPresent fails with NetCore")]
#else
[Fact]
Expand Down Expand Up @@ -207,7 +207,7 @@ public void RevertToSameIdentity()
logFactory.Shutdown();
}

#if NET35 || NET45 || NET46
#if NETFRAMEWORK
[Fact(Skip = "CreateUserIfNotPresent fails with NetCore")]
#else
[Fact]
Expand Down Expand Up @@ -242,7 +242,7 @@ public void ImpersonatingWrapperNegativeTest()
logFactory.Shutdown(); // will not fail because Initialize() failed
}

#if NET35 || NET45 || NET46
#if NETFRAMEWORK
[Fact(Skip = "CreateUserIfNotPresent fails with NetCore")]
#else
[Fact]
Expand Down Expand Up @@ -338,7 +338,7 @@ private void CreateUserIfNotPresent()
return;
}

#if NET35 || NET45 || NET46
#if NETFRAMEWORK
var user = new UserPrincipal(context);
user.SetPassword(NLogTestUserPassword);
user.Name = NLogTestUser;
Expand Down

0 comments on commit 4f77005

Please sign in to comment.