private void btnLogin_Click(object sender, EventArgs e)
{
if( txtUsername.Text.Length == 0 || txtPassword.Text.Length == 0 ) {
MessageBox.Show("用户名或者密码不能为空。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
string ldapPath = "LDAP://" + GetDomainName();
string domainAndUsername = Environment.UserDomainName + "\\" + txtUsername.Text;
DirectoryEntry entry = new DirectoryEntry(ldapPath, domainAndUsername, txtPassword.Text);
DirectorySearcher search = new DirectorySearcher(entry);
try {
SearchResult result = search.FindOne();
MessageBox.Show("登录成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch( Exception ex ) {
// 如果用户名或者密码不正确,也会抛出异常。
MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
请问这个在Foxtable中怎么写啊? 用于域验证