mirror of
https://github.com/freedbygrace/ActiveDirectoryToRestApi.git
synced 2026-07-26 11:28:20 +00:00
Add ldapS option
This commit is contained in:
@@ -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; }
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user