private static bool TestConnection(string path, string username, string password) { var ccs = Startup.CentralCertificateStore; try { using (SafeAccessTokenHandle ccsUser = CentralCertificateStore.LogonUser(username ?? ccs.UserName, password ?? ccs.Password)) { WindowsIdentity.RunImpersonated(ccsUser, () => { Directory.GetFiles(path); }); } } catch { return(false); } return(true); }
private void ConfigureStoreProvider() { ICertificateOptions options = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateOptions>(); ICertificateStoreProvider storeProvider = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <ICertificateStoreProvider>(); IFileProvider fileProvider = Environment.Host.ApplicationBuilder.ApplicationServices.GetRequiredService <IFileProvider>(); var ccsOptions = options.Stores.FirstOrDefault(s => s.Name.Equals(STORE_NAME, System.StringComparison.OrdinalIgnoreCase)); var store = new CentralCertificateStore(STORE_NAME, ccsOptions != null ? ccsOptions.Claims : new string[] { "read" }, fileProvider); if (CentralCertHelper.FeatureEnabled && store.Enabled) { storeProvider.AddStore(store); } CentralCertificateStore = store; }
public CentralCertsController(IFileProvider fileProvider) { _ccs = Startup.CentralCertificateStore; _fileProvider = fileProvider; }