private bool AuthenticateUser() { string username = tb_Username.Text; string password = pb_Password.Password; if (username == "" | password == "") { MessageBox.Show("You must enter both a username and a password"); return(false); } else { string ldapServer = ADAuthentication.getLdapServer(); if (ADAuthentication.authorizedUsers.Contains(username)) { try { ADAuthentication.bindToLDAPServer(ldapServer, username, password); MessageBox.Show("Login Successful"); return(true); } catch (LdapException lexc) { string errorMessage = ADAuthentication.returnErrorMessage(lexc); MessageBox.Show(errorMessage); return(false); } } else { MessageBox.Show("User is not authorized"); return(false); } } }
public MainWindow() { InitializeComponent(); ADAuthentication adauth = new ADAuthentication(); }