hi dharmendr sir,
hope you are fine.
sir i have login page I want to merge this page with active directory.
I mean login credential should be check from active directory.
Can u help me for updating my code.
My code is attached below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Configuration;
namespace foamSystem
{
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnlogin_Click(object sender, EventArgs e)
{
SqlConnection con;
con = new SqlConnection("Data Source=DESKTOP;Initial Catalog=save;Integrated Security=True");
if (con.State == ConnectionState.Closed)
con.Open();
string q = "select * from login where username = '" + txtname.Text + "' and password = '" + txtpass.Text + "'";
if (txtname.Text == "ccadmin")
{
SqlCommand cmd = new SqlCommand(q, con);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
Response.Redirect("HomePage.aspx");
}
}
else
{
SqlCommand cmd = new SqlCommand(q, con);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
Response.Redirect("Page.aspx");
}
}
}
}
}