Add option to work with ldapS on Linux

This commit is contained in:
Marcio
2024-07-25 00:46:57 -03:00
parent 46b737434e
commit dbd94ef7b5
2 changed files with 8 additions and 2 deletions
@@ -9,7 +9,7 @@
<UserSecretsId>d52504e9-ea6e-4152-a52e-467ca002e47c</UserSecretsId> <UserSecretsId>d52504e9-ea6e-4152-a52e-467ca002e47c</UserSecretsId>
<AssemblyVersion>$(PackageVersion)</AssemblyVersion> <AssemblyVersion>$(PackageVersion)</AssemblyVersion>
<FileVersion>$(PackageVersion)</FileVersion> <FileVersion>$(PackageVersion)</FileVersion>
<Version>1.0.0.3</Version> <Version>1.0.0.4</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+7 -1
View File
@@ -1,3 +1,5 @@
using System.Runtime.InteropServices;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers(); builder.Services.AddControllers();
@@ -36,11 +38,15 @@ builder.Services.AddSingleton(provider =>
{ {
AuthType = AuthType.Basic AuthType = AuthType.Basic
}; };
if (configs.UseSSL) if (configs.UseSSL && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{ {
ldapConnection.SessionOptions.SecureSocketLayer = true; ldapConnection.SessionOptions.SecureSocketLayer = true;
ldapConnection.SessionOptions.VerifyServerCertificate = (con, cert) => true; ldapConnection.SessionOptions.VerifyServerCertificate = (con, cert) => true;
} }
if (configs.UseSSL && RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
ldapConnection.SessionOptions.SecureSocketLayer = true;
}
ldapConnection.SessionOptions.ReferralChasing = ReferralChasingOptions.None; ldapConnection.SessionOptions.ReferralChasing = ReferralChasingOptions.None;
ldapConnection.Bind(); ldapConnection.Bind();
return ldapConnection; return ldapConnection;