mirror of
https://github.com/freedbygrace/ActiveDirectoryToRestApi.git
synced 2026-08-29 11:37:10 +00:00
Add ldapS option
This commit is contained in:
@@ -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.2</Version>
|
<Version>1.0.0.3</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
public class LdapConfigs
|
public class LdapConfigs
|
||||||
{
|
{
|
||||||
public string Server { get; set; }
|
public string Server { get; set; }
|
||||||
|
public int Port { get; set; }
|
||||||
|
public bool UseSSL { get; set; }
|
||||||
public string DomainName { get; set; }
|
public string DomainName { get; set; }
|
||||||
public string User { get; set; }
|
public string User { get; set; }
|
||||||
public string Pass { get; set; }
|
public string Pass { get; set; }
|
||||||
|
|||||||
@@ -30,12 +30,17 @@ builder.Services.AddSwaggerGen(s =>
|
|||||||
builder.Services.AddSingleton(provider =>
|
builder.Services.AddSingleton(provider =>
|
||||||
{
|
{
|
||||||
var configs = builder.Configuration.GetSection(nameof(LdapConfigs)).Get<LdapConfigs>();
|
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,
|
var ldapConnection = new LdapConnection(endpoint,
|
||||||
new NetworkCredential($"{configs.User}@{configs.DomainName}", configs.Pass))
|
new NetworkCredential($"{configs.User}@{configs.DomainName}", configs.Pass))
|
||||||
{
|
{
|
||||||
AuthType = AuthType.Basic
|
AuthType = AuthType.Basic
|
||||||
};
|
};
|
||||||
|
if (configs.UseSSL)
|
||||||
|
{
|
||||||
|
ldapConnection.SessionOptions.SecureSocketLayer = true;
|
||||||
|
ldapConnection.SessionOptions.VerifyServerCertificate = (con, cert) => true;
|
||||||
|
}
|
||||||
ldapConnection.SessionOptions.ReferralChasing = ReferralChasingOptions.None;
|
ldapConnection.SessionOptions.ReferralChasing = ReferralChasingOptions.None;
|
||||||
ldapConnection.Bind();
|
ldapConnection.Bind();
|
||||||
return ldapConnection;
|
return ldapConnection;
|
||||||
|
|||||||
@@ -2,7 +2,27 @@
|
|||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,34 @@
|
|||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"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": "*",
|
"AllowedHosts": "*",
|
||||||
"LdapConfigs": {
|
"LdapConfigs": {
|
||||||
"Server": "192.168.100.25",
|
"Server": "192.168.100.25",
|
||||||
|
"Port": 636,
|
||||||
|
"UseSSL": true,
|
||||||
"DomainName": "AD", // (pre-Windows 2000)
|
"DomainName": "AD", // (pre-Windows 2000)
|
||||||
"User": "ldapAdmin",
|
"User": "ldapAdmin",
|
||||||
"Pass": "Thi$1sMyPassw0rd",
|
"Pass": "Thi$1sMyPassw0rd",
|
||||||
|
|||||||
Reference in New Issue
Block a user