public void Dispose() { if (impersonator != null) { impersonator.Dispose(); impersonator = null; } }
public NetworkShareImpersonator(bool impersonate) { string username = Configuration.Services.NetworkImpersonation.Username; string password = Configuration.Services.NetworkImpersonation.GetPassword(); if (impersonate && Configuration.Services.NetworkImpersonation.IsEnabled()) { try { impersonator = new Impersonator(Configuration.Services.NetworkImpersonation.Domain, username, password); } catch (Exception e) { Log.Warn("Failed to impersonate {0} -> {1}", username, e.Message); impersonator = null; } } }
public NetworkShareImpersonator(bool impersonate) { string username = Configuration.Services.NetworkImpersonation.Username; string password = Configuration.Services.NetworkImpersonation.GetPassword(); if (impersonate && !String.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { try { impersonator = new Impersonator(Configuration.Services.NetworkImpersonation.Domain, username, password); } catch (Exception) { Log.Warn("Failed to impersonate {0}", username); impersonator = null; } } }