private void btnLogin_Click(object sender, System.EventArgs e) { try { ShowLogingError("", true); if (WindowsImpersonation.LogonUser(txtUserName.Text, txtDomainName.Text, txtPassword.Text)) { ShowLogingMsg("Current user: "******"Login has been made successfully.", true); DirectoryPrepare(); this.btnUpload.Disabled = false; } else { ShowLogingError("Authentication failed, check username and password.", false); } } catch (Exception ex) { ShowLogingMsg("Current user: "******"Error authenticating. " + ex.Message, false); } }
protected void Application_AuthenticateRequest(Object sender, EventArgs e) { WindowsImpersonation.Impersonate(); }