Hopefully I am not asking a dump question. After reading most of the forums of how to write the connection string in the webconfig file, I found all of their suggestions are hard code an user id and password in the connection strings.
My question is I list my User ID & Password in the connection string at webconfig file, will other users who access to the web site read it? Also, I have more than 100 users need to log into the web site, how can I hard code all 100 users' id & password into the connection string? I have the code in below in the
WebConfig
<
<add name="myDbConnectionString1"connectionStrings>
InitialCatalog='Testing';User ID = 'User1';Password='Password1'"/>
Here is the Login.aspx
namespace
{
{
{
}
{
sds.ConnectionString =
sds.SelectParameters.Add(
sds.SelectParameters.Add(
sds.SelectCommand =
{
}
{
Response.Redirect(
}
}
}
}
this.Session["username"] = dv[0].Row["username"].ToString();"SecurePage.aspx");Thank you.connectionStrings>
Ankit NandekarPosted Apr 27, 2011, 1:45 AM
Ankit NandekarPosted Apr 29, 2011, 3:22 AM
omkar mhaiskarPosted Apr 29, 2011, 2:59 AM
for this you need not to create or value stored in web config file.
FOr this you need to create one page in which you just store hardcoded role and it's respective keyword.
proviode one text box on that page ask there to put keyword. thorugh this you will get respective information.
after that you can do it what ever you want.
EggyPosted Apr 28, 2011, 12:24 PM
thanks for the replied.
I did store users id & password in database. Also, I don't have a register page for user to create his/her own user id and password.
So, for my understand:
1) In the webconfig page, there is a particular user id and password (hard code) so then when an user enter the password, the web site will redirect the right page if the user and password has been checked?
2) Other users will be authorized (by the role in table), then redirect to the right page
3) Otherwise, stranger user will redirect to the page to login again?
Thank you.
Anil KumarPosted Apr 27, 2011, 3:59 AM
-> Authenticate the user
-> Check the Role (authorization)
-> Redirect him at appropriate home page based on his role & access.
You can do that as -
-> Check the user existence in database
(you can do it by just storing the database connection string in your web.config file. In this you specify user id & password for connecting DB and it can be used common irrespective of users login details. Users login detail can be stored in a table.
once you connected the database using webconfig, you check if the user is in table.)
-> If userExist then Check the Role and redirect him accordingly
Otherwise Show the login credential error.
----------------------------------------------------------------------------
Mark it as Answered if it is helpful.
Manikavelu VelayuthamPosted Apr 27, 2011, 1:38 AM
Database Connection string credentials is not going to vary for all the users. Its going to be only one.
Login credentials of each users should be stored in that particular database.
Based on thier username and password supplied through the page, you need to vaildate the particualr user.
Jaganathan BantheswaranPosted Apr 27, 2011, 1:32 AM
Three options are there for your query.
1. Its better to store username password in DB.
2. If your website provides the option to register the user online, then write the username and password in webconfig file or a separate xml file and use it to login.
3. Hard code your user name and password in separate XML file and use it to Login.