473,326 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Custom Authentication without Server

Hi,

I want to implement my own "primitive" Authentication.
I use following code in web.config:

<authentication mode="Forms">
<forms name="FwLoginCookie"
loginUrl="Login.aspx"
protection="All"
timeout="30"
path="/"
requireSSL="false">
<credentials passwordFormat="Clear">
<user name="private" password="private" />
<user name="test" password="test" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>

I created a Login.aspx page. When I try to login with test (test) I get
an sql server error:

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: SQL Network Interfaces, error: 26 - Error
Locating Server/Instance Specified)

How do I create a page so I can log in with the credentials provided
within web.config?

Can I use the Login control and provide my own login (e.g. implemented
in my own library)?

Regards,

Rudi
Apr 4 '07 #1
7 1474
On Apr 4, 10:15 am, Rudi Hausmann <rudi...@nospam.comwrote:
I created a Login.aspx page. When I try to login with test (test) I get
an sql server error:

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: SQL Network Interfaces, error: 26 - Error
Locating Server/Instance Specified)
Are you sure that this error occured on the login.aspx?
login.aspx redirects back to the original page

Apr 4 '07 #2
Alexey Smirnov wrote:
On Apr 4, 10:15 am, Rudi Hausmann <rudi...@nospam.comwrote:
>I created a Login.aspx page. When I try to login with test (test) I get
an sql server error:

An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: SQL Network Interfaces, error: 26 - Error
Locating Server/Instance Specified)

Are you sure that this error occured on the login.aspx?
login.aspx redirects back to the original page
Yes, I am. When I press the Log In button I get the error above. I just
want the credentials to be read from web.config and not from a database
which I didn't set up and which I also don't want to set up.
Apr 4 '07 #3
On Apr 4, 11:36 am, Rudi Hausmann <rudi...@nospam.comwrote:
Yes, I am. When I press the Log In button I get the error above. I just
want the credentials to be read from web.config and not from a database
which I didn't set up and which I also don't want to set up.
Okay. Let's test it. Take my login.aspx and try to login with any of
your name

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Security " %>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="Form1" runat="server">

Name:<br />
<input id="UserName" type="text" runat="server"><br />

Password:<br />
<input id="Password1" type="password" runat="server"><br />

<input type="submit" OnServerClick="SubmitBtn_Click" runat="server"
ID="Submit1" NAME="Submit1" value="Try login!">

<asp:Label id="lblMsg" runat="server" />
</form>
<script language="vb" runat="server">

Sub SubmitBtn_Click(ByVal Source as Object, ByVal E as EventArgs)
If FormsAuthentication.Authenticate(Username.Value, UserPass.Value)
Then
FormsAuthentication.RedirectFromLoginPage (UserName.Value, false)
else
lblMsg.text="Credentials not valid!"
End If
End Sub

</script>
</body>
</HTML>

Apr 4 '07 #4
On Apr 4, 11:50 am, "Alexey Smirnov" <alexey.smir...@gmail.comwrote:
On Apr 4, 11:36 am, Rudi Hausmann <rudi...@nospam.comwrote:
Yes, I am. When I press the Log In button I get the error above. I just
want the credentials to be read from web.config and not from a database
which I didn't set up and which I also don't want to set up.

Okay. Let's test it. Take my login.aspx and try to login with any of
your name

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Security " %>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="Form1" runat="server">

Name:<br />
<input id="UserName" type="text" runat="server"><br />

Password:<br />
<input id="Password1" type="password" runat="server"><br />

<input type="submit" OnServerClick="SubmitBtn_Click" runat="server"
ID="Submit1" NAME="Submit1" value="Try login!">

<asp:Label id="lblMsg" runat="server" />
</form>
<script language="vb" runat="server">

Sub SubmitBtn_Click(ByVal Source as Object, ByVal E as EventArgs)
If FormsAuthentication.Authenticate(Username.Value, UserPass.Value)
Then
FormsAuthentication.RedirectFromLoginPage (UserName.Value, false)
else
lblMsg.text="Credentials not valid!"
End If
End Sub

</script>
</body>
</HTML>
Wait, add another Test.aspx form with the following code (just one
line of code):

----------
My User Name is: <%=User.Identity.Name%>
----------

Then

1) call this page http://localhost/Test.aspx
2) it will forward you http://localhost/Login.aspx
3) type username / password
4) if username / password were correct you will be redirected back to
http://localhost/Test.aspx
5) you should see your username

Apr 4 '07 #5
Hi Alexey,

Thanks a lot for answer and your effort!
I adapted the code until it run fine on my machine. (The code is below.)
Having your keywords in your code it`s much easier to come further.

I guess when exchange "FormsAuthentication.Authenticate" with
"MyOwnLogInTest(user,pass)" I can have my own authentication.

Moreover I assume that I can't use the asp.net login controls.

Regards,

Rudi

-------------------------------------
<%@ Page Language="VB" %>

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Security " %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Test</title>
</head>
<body>
<form id="Form1" runat="server">
Name:<br />
<input id="UserName" type="text" runat="server" /><br />
Password:<br />
<input id="UserPass" type="password" runat="server" /><br />
<input type="submit" onserverclick="SubmitBtn_Click"
runat="server" id="Submit1"
name="Submit1" value="Try login!" />
<asp:Label ID="lblMsg" runat="server" />
</form>

<script language="vb" runat="server">

Sub SubmitBtn_Click(ByVal Source As Object, ByVal E As EventArgs)
If FormsAuthentication.Authenticate(UserName.Value,
UserPass.Value) Then

FormsAuthentication.RedirectFromLoginPage(UserName .Value, False)
Else
lblMsg.Text = "Credentials not valid!"
End If
End Sub

</script>

</body>
</html>
Alexey Smirnov wrote:
On Apr 4, 11:36 am, Rudi Hausmann <rudi...@nospam.comwrote:
>Yes, I am. When I press the Log In button I get the error above. I just
want the credentials to be read from web.config and not from a database
which I didn't set up and which I also don't want to set up.

Okay. Let's test it. Take my login.aspx and try to login with any of
your name

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Security " %>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="Form1" runat="server">

Name:<br />
<input id="UserName" type="text" runat="server"><br />

Password:<br />
<input id="Password1" type="password" runat="server"><br />

<input type="submit" OnServerClick="SubmitBtn_Click" runat="server"
ID="Submit1" NAME="Submit1" value="Try login!">

<asp:Label id="lblMsg" runat="server" />
</form>
<script language="vb" runat="server">

Sub SubmitBtn_Click(ByVal Source as Object, ByVal E as EventArgs)
If FormsAuthentication.Authenticate(Username.Value, UserPass.Value)
Then
FormsAuthentication.RedirectFromLoginPage (UserName.Value, false)
else
lblMsg.text="Credentials not valid!"
End If
End Sub

</script>
</body>
</HTML>
Apr 4 '07 #6
Alexey Smirnov wrote:
On Apr 4, 11:50 am, "Alexey Smirnov" <alexey.smir...@gmail.comwrote:
>On Apr 4, 11:36 am, Rudi Hausmann <rudi...@nospam.comwrote:
>>Yes, I am. When I press the Log In button I get the error above. I just
want the credentials to be read from web.config and not from a database
which I didn't set up and which I also don't want to set up.
Okay. Let's test it. Take my login.aspx and try to login with any of
your name

<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Security " %>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="Form1" runat="server">

Name:<br />
<input id="UserName" type="text" runat="server"><br />

Password:<br />
<input id="Password1" type="password" runat="server"><br />

<input type="submit" OnServerClick="SubmitBtn_Click" runat="server"
ID="Submit1" NAME="Submit1" value="Try login!">

<asp:Label id="lblMsg" runat="server" />
</form>
<script language="vb" runat="server">

Sub SubmitBtn_Click(ByVal Source as Object, ByVal E as EventArgs)
If FormsAuthentication.Authenticate(Username.Value, UserPass.Value)
Then
FormsAuthentication.RedirectFromLoginPage (UserName.Value, false)
else
lblMsg.text="Credentials not valid!"
End If
End Sub

</script>
</body>
</HTML>

Wait, add another Test.aspx form with the following code (just one
line of code):

----------
My User Name is: <%=User.Identity.Name%>
----------

Then

1) call this page http://localhost/Test.aspx
2) it will forward you http://localhost/Login.aspx
3) type username / password
4) if username / password were correct you will be redirected back to
http://localhost/Test.aspx
5) you should see your username
Works fine. I see what should see :-)
Thank you!
Apr 4 '07 #7
On Apr 4, 12:19 pm, Rudi Hausmann <rudi...@nospam.comwrote:
Alexey Smirnov wrote:
On Apr 4, 11:50 am, "Alexey Smirnov" <alexey.smir...@gmail.comwrote:
On Apr 4, 11:36 am, Rudi Hausmann <rudi...@nospam.comwrote:
>Yes, I am. When I press the Log In button I get the error above. I just
want the credentials to be read from web.config and not from a database
which I didn't set up and which I also don't want to set up.
Okay. Let's test it. Take my login.aspx and try to login with any of
your name
<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Security " %>
<HTML>
<HEAD>
<title>Test</title>
</HEAD>
<body>
<form id="Form1" runat="server">
Name:<br />
<input id="UserName" type="text" runat="server"><br />
Password:<br />
<input id="Password1" type="password" runat="server"><br />
<input type="submit" OnServerClick="SubmitBtn_Click" runat="server"
ID="Submit1" NAME="Submit1" value="Try login!">
<asp:Label id="lblMsg" runat="server" />
</form>
<script language="vb" runat="server">
Sub SubmitBtn_Click(ByVal Source as Object, ByVal E as EventArgs)
If FormsAuthentication.Authenticate(Username.Value, UserPass.Value)
Then
FormsAuthentication.RedirectFromLoginPage (UserName.Value, false)
else
lblMsg.text="Credentials not valid!"
End If
End Sub
</script>
</body>
</HTML>
Wait, add another Test.aspx form with the following code (just one
line of code):
----------
My User Name is: <%=User.Identity.Name%>
----------
Then
1) call this pagehttp://localhost/Test.aspx
2) it will forward youhttp://localhost/Login.aspx
3) type username / password
4) if username / password were correct you will be redirected back to
http://localhost/Test.aspx
5) you should see your username

Works fine. I see what should see :-)
Thank you!- Hide quoted text -

- Show quoted text -
Kein Problem :-)

Apr 4 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Nick | last post by:
the customError feature is not working. I have it setup as the help says in my web.config file. <customErrors defaultRedirect="DsAppError.aspx" mode="RemoteOnly"/> I tried in a couple...
6
by: Jéjé | last post by:
Hi, I have a custom aspx page which access RS (Reporting Services) using the webservice interface. I'm using the delegation (defautcredentialcache) to send the user authentication to RS. RS...
5
by: Jon Skeet [C# MVP] | last post by:
I've run against a problem which I'm *sure* must be easy to solve - but I'm blowed if I can find the answer :( I have a web service which I want to require authentication. I need to authenticate...
1
by: Jakob Lithner | last post by:
When I started a new ASP project I was eager to use the login facilities offered in Framework 2.0/VS 2005. I wanted: - A custom principal that could hold my integer UserID from the database -...
6
by: =?Utf-8?B?UGFyYWcgR2Fpa3dhZA==?= | last post by:
Hi All, We have a requirement where we have to develop a custom Login Page which will accept user's NT credentials ( Username , password, domain name). This then needs to be passed to a website...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.