0

I am as a study project developed a website in ASP.net. In my web.config file i have autheticaion mode as windows. and i am using an appsettings connection string to connect to my SQL2005 database. Now i want to know what kind of authentication is this? Is this windows? forms? or anonymous authentication?

I have user table in sql 2005 and my first screen is login page. Obviously this user table has login details like username and password which will be matched to user input.

I dont understand i have read so many post on authorization and authienticaion but please clear me on this. Thanks in advance.

5
  • 1
    So you're asking about how to make a Login Page for User base on User Table ? Commented Oct 29, 2012 at 10:24
  • You said Authentication mode is windows and you also asked - what kind of authentication is this? I think you need to be clear what you asking for Commented Oct 29, 2012 at 10:27
  • No, i just want to know the what authorization/authentication is this? I mean i have read so many articels which tell in detail about forms, windows authentication. But sort of authenticaion i have used? in my webconfig, authenticatio mode is windows and i am connecting to SQL server for login. Commented Oct 29, 2012 at 10:27
  • Codingbiz - thanks for replying. but i am connecting to SQL for login. So does taht make it forms authentication? Commented Oct 29, 2012 at 10:28
  • <authentication mode="Windows" /> <authorization> <allow users="*"/> </authorization> <appSettings> <add key="ConnectionString" value="server=LocalX1; uid=sa; pwd=; database=Test45;Connect Timeout=800000"/> this is my web.config file settings.. and i am the above database to validate login and save it in session. so can anybody put light on authentication and authorization of this project pleaseee Commented Oct 29, 2012 at 10:41

3 Answers 3

4

You are currently using Windows authentication. Your Windows username and password is used to authenticate you to asp.net.

A login page writing to a user table would be asp.net forms authentication.

Note that sql server authentication is a totally separate issue. It is up to your code to authenticate against your database. When doing so, the connection string in web.config file can be used.

Sign up to request clarification or add additional context in comments.

2 Comments

Sir thanks for your reply. So i am using both? Windows as well as forms authentication?
Sorry guys, i was using a webservice method to connect to the database. In my website web.config file i had authentication mode set to forms and the webconfig file of my webservice (asmx) was windows. So that means my website is doing forms authentication. and my webservice is windows authentication. Confusion was because there are two different web.config files. Its clear now. You guys thanks all. Brilliant!!
1

If you want customize your credentials of string connection in order to access your DataBase, you can use Integrated Security or Trusted_Connection

When the value is true, the current credentials of the Windows account used for authentication.

Nota : in yur case i think that you can use FormsAuthentification (You have Windows Authentification)

Link : http://msdn.microsoft.com/fr-fr/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.80).aspx

Forms Authentification :

<authentication mode="Forms">
 <forms loginUrl="~/login.aspx">
</forms>
</authentication> 
<authorization>
  <deny users="?" />
</authorization>

After your click

 if (IsAuthenticatedValue) //You can adjust  your condition
  {
      FormsAuthentication.RedirectFromLoginPage (.., ..);
  }
  else
  {
      Console.WriteLine("Invalid credentials. Please try again.");
  }

Link : http://msdn.microsoft.com/fr-fr/library/xdt4thhy(v=vs.80).aspx

4 Comments

<authentication mode="Windows" /> <authorization> <allow users="*"/> </authorization> <appSettings> <add key="ConnectionString" value="server=LocalX1; uid=sa; pwd=; database=Test45;Connect Timeout=800000"/> this is my web.config file settings.. and i am the above database to validate login and save it in session. so can anybody put light on authentication and authorization of this project pleaseee
<authentication mode="Forms"> <forms loginUrl="~/login.aspx"> </forms></authentication>
Sorry guys, i was using a webservice method to connect to the database. In my website web.config file i had authentication mode set to forms and the webconfig file of my webservice (asmx) was windows. So that means my website is doing forms authentication. and my webservice is windows authentication. Confusion was because there are two different web.config files. Its clear now. You guys thanks all. Brilliant!!
Thanks a lot Candie. Because of you explanation i was able to do it. Thanks!
0

In addition to the other answer here:

Once the user is logged in, create a Session and store the fact they are logged in using that such as

Session["LoggedIn"] = true; 
Session["Username"] = username;

Then check if they are logged in using your Code and authorise access to the page using that. So on page load if they logged in continue loading the page, else send them to the login page.

When you want to log the user off simply do Session.Clear();

2 Comments

Thanks Ryan. I have done this. Just can u confirm if this is right. I am using windows authentication, and i a using sql server as my database?
Sorry guys, i was using a webservice method to connect to the database. In my website web.config file i had authentication mode set to forms and the webconfig file of my webservice (asmx) was windows. So that means my website is doing forms authentication. and my webservice is windows authentication. Confusion was because there are two different web.config files. Its clear now. You guys thanks all. Brilliant!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.