mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added logging, added Elmah error logging
This commit is contained in:
@@ -12,11 +12,13 @@ public class LdapService : IDisposable
|
||||
{
|
||||
private readonly LdapOptions _opts;
|
||||
private readonly LdapConnection _conn;
|
||||
private ILogger _logger;
|
||||
|
||||
public LdapService(IOptions<LdapOptions> options)
|
||||
public LdapService(IOptions<LdapOptions> options, ILogger<LdapService> logger)
|
||||
{
|
||||
_opts = options.Value;
|
||||
_conn = new LdapConnection { SecureSocketLayer = _opts.UseSsl };
|
||||
_logger = logger;
|
||||
ConnectAndBind();
|
||||
}
|
||||
|
||||
@@ -26,7 +28,15 @@ public class LdapService : IDisposable
|
||||
{
|
||||
Console.WriteLine(_opts.Host);
|
||||
Console.WriteLine(_opts.Port);
|
||||
_conn.Connect(_opts.Host, _opts.Port);
|
||||
try
|
||||
{
|
||||
_conn.Connect(_opts.Host, _opts.Port);
|
||||
}
|
||||
catch (SystemException ex)
|
||||
{
|
||||
_logger.LogCritical("Unable to connect to LDAP: {ex.Message}\n{ex.StackTrace}", [ex.Message, ex.StackTrace]);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
_conn.Bind(_opts.BindDn, _opts.BindPassword);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user