Add ldapS option

This commit is contained in:
Marcio
2024-07-25 00:04:43 -03:00
parent c9657dd57d
commit 46b737434e
5 changed files with 53 additions and 4 deletions
@@ -9,7 +9,7 @@
<UserSecretsId>d52504e9-ea6e-4152-a52e-467ca002e47c</UserSecretsId>
<AssemblyVersion>$(PackageVersion)</AssemblyVersion>
<FileVersion>$(PackageVersion)</FileVersion>
<Version>1.0.0.2</Version>
<Version>1.0.0.3</Version>
</PropertyGroup>
<ItemGroup>
@@ -3,6 +3,8 @@
public class LdapConfigs
{
public string Server { get; set; }
public int Port { get; set; }
public bool UseSSL { get; set; }
public string DomainName { get; set; }
public string User { get; set; }
public string Pass { get; set; }
+6 -1
View File
@@ -30,12 +30,17 @@ builder.Services.AddSwaggerGen(s =>
builder.Services.AddSingleton(provider =>
{
var configs = builder.Configuration.GetSection(nameof(LdapConfigs)).Get<LdapConfigs>();
var endpoint = new LdapDirectoryIdentifier(configs.Server, false, false);
var endpoint = new LdapDirectoryIdentifier(configs.Server, configs.Port, configs.UseSSL ? true : false, false);
var ldapConnection = new LdapConnection(endpoint,
new NetworkCredential($"{configs.User}@{configs.DomainName}", configs.Pass))
{
AuthType = AuthType.Basic
};
if (configs.UseSSL)
{
ldapConnection.SessionOptions.SecureSocketLayer = true;
ldapConnection.SessionOptions.VerifyServerCertificate = (con, cert) => true;
}
ldapConnection.SessionOptions.ReferralChasing = ReferralChasingOptions.None;
ldapConnection.Bind();
return ldapConnection;
@@ -2,7 +2,27 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Warning"
},
"Console": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Warning"
},
"FormatterName": "json",
"FormatterOptions": {
"SingleLine": true,
"IncludeScopes": false,
"TimestampFormat": "dd/MM/yyyy HH:mm:ss",
"UseUtcTimestamp": false,
"JsonWriterOptions": {
"Indented": false
}
}
}
}
}
+23 -1
View File
@@ -2,12 +2,34 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Warning"
},
"Console": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Warning"
},
"FormatterName": "json",
"FormatterOptions": {
"SingleLine": true,
"IncludeScopes": false,
"TimestampFormat": "dd/MM/yyyy HH:mm:ss",
"UseUtcTimestamp": false,
"JsonWriterOptions": {
"Indented": false
}
}
}
},
"AllowedHosts": "*",
"LdapConfigs": {
"Server": "192.168.100.25",
"Port": 636,
"UseSSL": true,
"DomainName": "AD", // (pre-Windows 2000)
"User": "ldapAdmin",
"Pass": "Thi$1sMyPassw0rd",