Below is the methods I was written in DAL layer
public DataSet IsLoginCheck()
{
try
{
string connectionString = sql.ConnectionString();
SqlConnection con = new SqlConnection();
con.ConnectionString = connectionString;
con.Open();
SqlCommand cmd = new SqlCommand("GetUser", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserID", objBOL._UserName);
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da = new SqlDataAdapter(cmd);
da.Fill(ds);
con.Close();
return ds;
}
catch
{
throw;
}
}
======================================================================
Below are the methods I was written in BLL layer
public bool IsAuthenticated(string username, string pwd)
{
_path="LDAP://#";
string domainAndUsername = "#" + @"\" + username;
DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);
try
{
object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if (null == result)
{
return false;
}
_path = result.Path;
_filterAttribute = (string)result.Properties["cn"][0];
}
catch
{
throw;
}
return true;
}
------------------------------
public DataSet Login()
{
DataSet ds = new DataSet();
ds = _LoginDAL.IsLoginCheck();
return ds;
}
===========================================================
Please help me how do I authenticate the ad username in UI.
-If AD useraname and pwd correct means send to next page else it shows error
Help me please.