Click to See Complete Forum and Search --> : forms authentication


kscdavefl
March 16th, 2004, 02:08 PM
I am developing a web app and I am trying to use forms authentication. The web.config is as follows:

<authentication mode="Forms">
<forms name="authCookie" path="/" loginUrl="Login.aspx" protection="All" timeout="30">
</forms>
</authentication>

<authorization>
<deny users="?" /> <!-- Allow all users -->
-->
</authorization>

The code is as follows:

private void loginButton_Click(object sender, System.EventArgs e)
{
VerifyUser();
}


private void VerifyUser()
{
string user = userText.Text;
string password = passwordText.Text;
string database = databaseList.SelectedItem.ToString();
string strConnect = "Provider=\"MSDAORA.1\";User ID=" + user + ";Data Source=" + database + ";Password=" + password;
OleDbConnection cn = new OleDbConnection(strConnect);
cn.Open();
if (FormsAuthentication.Authenticate(userText.Text, passwordText.Text))
{
FormsAuthentication.SetAuthCookie("authCookie", false);
Response.Redirect("default.aspx");
}
else
{
messageLabel.Text = "Invalid login credentials";
}
cn.Close();
}

I know i need some authentication code but I have no idea what it is. Could someone please help with this. The only thing I can find on the web has to do with role based forms authentication. I am not using roles so this is useless to me. Please, I need some help with ther code.

Thanks,

Dave