日期:2014-05-17 浏览次数:20446 次
protected void Sub_Click( object sender, EventArgs e)
{
if (TextBox_Name.Text == string.Empty || TextBox_Pwd.Text == string.Empty)
{
Response.Write("<script>alert('You don't enter username or password, please input it!');</script>");
return;
}
string ldapPath = "LDAP://" + GetDomainName();
string domainAndUsername = Environment.UserDomainName + "\\" + TextBox_Name.Text;
DirectoryEntry entry = new DirectoryEntry(ldapPath, domainAndUsername, TextBox_Pwd.Text);
DirectorySearcher search = new DirectorySearcher(entry);
try
{
SearchResult result = search.FindOne();
// Response.Write("<script>alert('login successful');</script>");
Session["UserID"] = TextBox_Name.Text.Trim();
Response.Redirect("index.aspx");
}
catch (Exception ex)
{