Skip to content

Commit

Permalink
Windows integrated security #if directive for mono
Browse files Browse the repository at this point in the history
  • Loading branch information
jjchiw committed Dec 20, 2013
1 parent e6d784e commit af0548a
Show file tree
Hide file tree
Showing 6 changed files with 386 additions and 15 deletions.
80 changes: 80 additions & 0 deletions Npgsql.EntityFramework/Npgsql.EntityFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,86 @@
<DocumentationFile>bin\Release-net40\Npgsql.EntityFramework.xml</DocumentationFile>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net45|AnyCPU'">
<OutputPath>bin\Mono-Release-net45\</OutputPath>
<DefineConstants>TRACE;UNMANAGED;NET35;NET40;NET45;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Release-net45\Npgsql.EntityFramework.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net20|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net20\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;NET45;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Debug-net45\Npgsql.EntityFramework.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net35|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net35\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;NET45;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Debug-net45\Npgsql.EntityFramework.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net40|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net40\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Debug-net40\Npgsql.EntityFramework.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net45|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net45\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;NET45;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Debug-net45\Npgsql.EntityFramework.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net20|AnyCPU'">
<OutputPath>bin\Mono-Release-net20\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35;NET40;NET45;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Release-net45\Npgsql.EntityFramework.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net35|AnyCPU'">
<OutputPath>bin\Mono-Release-net35\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35;NET40;NET45;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Release-net45\Npgsql.EntityFramework.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net40|AnyCPU'">
<OutputPath>bin\Mono-Release-net40\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35;NET40;ENTITIES6</DefineConstants>
<DocumentationFile>bin\Release-net40\Npgsql.EntityFramework.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.0.1\lib\net40\EntityFramework.dll</HintPath>
Expand Down
86 changes: 82 additions & 4 deletions Npgsql.EntityFramework/Npgsql.EntityFrameworkLegacy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,86 @@
<DocumentationFile>bin\Legacy-Release-net35\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net45|AnyCPU'">
<OutputPath>bin\Mono-Release-net45\</OutputPath>
<DefineConstants>TRACE;UNMANAGED;NET35;NET40;NET45</DefineConstants>
<DocumentationFile>bin\Legacy-Release-net45\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net20|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net20\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;NET45</DefineConstants>
<DocumentationFile>bin\Legacy-Debug-net45\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net35|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net35\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35</DefineConstants>
<DocumentationFile>bin\Legacy-Debug-net35\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net40|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net40\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40</DefineConstants>
<DocumentationFile>bin\Legacy-Debug-net40\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net45|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net45\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;NET45</DefineConstants>
<DocumentationFile>bin\Legacy-Debug-net45\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net20|AnyCPU'">
<OutputPath>bin\Mono-Release-net20\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35;NET40;NET45</DefineConstants>
<DocumentationFile>bin\Legacy-Release-net45\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net35|AnyCPU'">
<OutputPath>bin\Mono-Release-net35\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35</DefineConstants>
<DocumentationFile>bin\Legacy-Release-net35\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net40|AnyCPU'">
<OutputPath>bin\Mono-Release-net40\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35;NET40</DefineConstants>
<DocumentationFile>bin\Legacy-Release-net40\Npgsql.EntityFrameworkLegacy.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -127,14 +207,12 @@
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\Npgsql\Npgsql.csproj">
<Project>{9d13b739-62b1-4190-b386-7a9547304eb3}</Project>
<Name>Npgsql</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
86 changes: 83 additions & 3 deletions Npgsql/Npgsql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,86 @@
<DocumentationFile>bin\Release-net20\Npgsql.xml</DocumentationFile>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net45|AnyCPU'">
<OutputPath>bin\Mono-Release-net45\</OutputPath>
<DefineConstants>TRACE;UNMANAGED;NET35;NET40;NET45;ENTITIES</DefineConstants>
<DocumentationFile>bin\Release-net45\Npgsql.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net20|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net20\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED</DefineConstants>
<DocumentationFile>bin\Debug-net20\Npgsql.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net35|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net35\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;ENTITIES</DefineConstants>
<DocumentationFile>bin\Debug-net35\Npgsql.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net40|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net40\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;ENTITIES</DefineConstants>
<DocumentationFile>bin\Debug-net40\Npgsql.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Debug-net45|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Mono-Debug-net45\</OutputPath>
<DefineConstants>TRACE;DEBUG;WINDOWS;UNMANAGED;NET35;NET40;NET45;ENTITIES</DefineConstants>
<DocumentationFile>bin\Debug-net45\Npgsql.xml</DocumentationFile>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net20|AnyCPU'">
<OutputPath>bin\Mono-Release-net20\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED</DefineConstants>
<DocumentationFile>bin\Release-net20\Npgsql.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net35|AnyCPU'">
<OutputPath>bin\Mono-Release-net35\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35;ENTITIES</DefineConstants>
<DocumentationFile>bin\Release-net35\Npgsql.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Mono-Release-net40|AnyCPU'">
<OutputPath>bin\Mono-Release-net40\</OutputPath>
<DefineConstants>TRACE;WINDOWS;UNMANAGED;NET35;NET40;ENTITIES</DefineConstants>
<DocumentationFile>bin\Release-net40\Npgsql.xml</DocumentationFile>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -129,12 +209,12 @@
<Reference Include="System.Configuration" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug-net40' Or '$(Configuration)' == 'Release-net40' Or '$(Configuration)' == 'Debug-net45' Or '$(Configuration)' == 'Release-net45' ">
<ItemGroup Condition=" '$(Configuration)' == 'Debug-net40' Or '$(Configuration)' == 'Release-net40' Or '$(Configuration)' == 'Debug-net45' Or '$(Configuration)' == 'Release-net45'&#xD;&#xA; OR '$(Configuration)' == 'Mono-Debug-net40' Or '$(Configuration)' == 'Mono-Release-net40' Or '$(Configuration)' == 'Mono-Debug-net45' Or '$(Configuration)' == 'Mono-Release-net45'">
<Reference Include="Mono.Security">
<HintPath>..\lib\Mono.Security\4.0\Mono.Security.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug-net20' Or '$(Configuration)' == 'Release-net20' Or '$(Configuration)' == 'Debug-net35' Or '$(Configuration)' == 'Release-net35' ">
<ItemGroup Condition=" '$(Configuration)' == 'Debug-net20' Or '$(Configuration)' == 'Release-net20' Or '$(Configuration)' == 'Debug-net35' Or '$(Configuration)' == 'Release-net35' &#xD;&#xA; OR '$(Configuration)' == 'Mono-Debug-net20' Or '$(Configuration)' == 'Mono-Release-net20' Or '$(Configuration)' == 'Mono-Debug-net35' Or '$(Configuration)' == 'Mono-Release-net35'">
<Reference Include="Mono.Security">
<HintPath>..\lib\Mono.Security\2.0\Mono.Security.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -611,4 +691,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
19 changes: 13 additions & 6 deletions Npgsql/Npgsql/NpgsqlConnectionStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,25 @@ public string UserName
{
get
{
if ((_integrated_security) && (String.IsNullOrEmpty(_username)))
{
System.Security.Principal.WindowsIdentity identity =
System.Security.Principal.WindowsIdentity.GetCurrent();
_username = identity.Name.Split('\\')[1];
}
#if WINDOWS
SetUsernameWindowsIntegratedSecurity();
#endif
return _username;
}

set { SetValue(GetKeyName(Keywords.UserName), Keywords.UserName, value); }
}

private void SetUsernameWindowsIntegratedSecurity()
{
if ((_integrated_security) && (String.IsNullOrEmpty(_username)))
{
System.Security.Principal.WindowsIdentity identity =
System.Security.Principal.WindowsIdentity.GetCurrent();
_username = identity.Name.Split('\\')[1];
}
}

private PasswordBytes _password;
/// <summary>
/// Gets or sets the login password as a UTF8 encoded byte array.
Expand Down

0 comments on commit af0548a

Please sign in to comment.