Skip to content

Commit

Permalink
Add System.Security.Principal.Windows nuget package instead of condit…
Browse files Browse the repository at this point in the history
…ional .NET Standard code
  • Loading branch information
Yitzchok authored and grumpydev committed May 18, 2019
1 parent 4b686a5 commit 465ec84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/Nancy.Hosting.Self/Nancy.Hosting.Self.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@
<PackageTags>$(PackageTags);Host</PackageTags>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Security.Principal.Windows">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>
</Project>
4 changes: 0 additions & 4 deletions src/Nancy.Hosting.Self/NancyHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ private string GetUser()
{
return !string.IsNullOrWhiteSpace(this.configuration.UrlReservations.User)
? this.configuration.UrlReservations.User
#if CORE
: string.Empty;
#else
: WindowsIdentity.GetCurrent().Name;
#endif
}

/// <summary>
Expand Down
8 changes: 2 additions & 6 deletions src/Nancy.Hosting.Self/UrlReservations.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
namespace Nancy.Hosting.Self
{
using System;
#if !CORE
using System.Security.Principal;
#endif

/// <summary>
/// Configuration for automatic url reservation creation
/// </summary>
public class UrlReservations
{
private const string EveryoneAccountName = "Everyone";
#if !CORE

private static readonly IdentityReference EveryoneReference =
new SecurityIdentifier(WellKnownSidType.WorldSid, null);
#endif

public UrlReservations()
{
this.CreateAutomatically = false;
Expand All @@ -39,13 +37,11 @@ private static string GetEveryoneAccountName()
try
{

#if !CORE
var account = EveryoneReference.Translate(typeof(NTAccount)) as NTAccount;
if (account != null)
{
return account.Value;
}
#endif
return EveryoneAccountName;
}
catch (Exception)
Expand Down

0 comments on commit 465ec84

Please sign in to comment.