473,399 Members | 2,146 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,399 software developers and data experts.

user login problems

I have some login code that works fine on several local machines, but
always fails when uploaded. I think it has something to do with
encryption. Here is the Submit_Click event which when the code is
uploaded always sets newUser to null, so I always get 'Login failed'.
PhilePrincipal.ValidateLogin is called to set the value of newUser and
this involves encryption (see code below). That is the only reason I
can think of why it is not working. Any ideas?

private void Submit_Click(object sender, System.EventArgs e)
{
PhilePrincipal newUser = PhilePrincipal.ValidateLogin(
EmailAddress.Text, Password.Text );
if (newUser == null)
{
LoginResult.Text = "Login failed for " + EmailAddress.Text;
LoginResult.Visible = true;
}
else
{
Context.User = newUser;
FormsAuthentication.SetAuthCookie( EmailAddress.Text, true );
Response.Redirect("default.aspx");
}
}

public static PhilePrincipal ValidateLogin(string emailAddress, string
password)
{
Configuration.ModuleSettings moduleSettings =
Configuration.ModuleConfig.GetSettings();
int newID;
byte[] cryptPassword = EncryptPassword( password );

Data.User dataUser = new Data.User( moduleSettings.ConnectionString
);
if ( (newID = dataUser.ValidateLogin(emailAddress, cryptPassword)) >
-1 )
return new PhilePrincipal( newID );
else
return null;
}

public static byte[] EncryptPassword(string password)
{
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] hashBytes = encoding.GetBytes( password );
// compute SHA-1 hash.
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] cryptPassword = sha1.ComputeHash ( hashBytes );
return cryptPassword;
}
Cheers,

Mike


*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
1 2595
After reading your code I suggest you read the following:

http://www.unixwiz.net/techtips/igui...tml#digestonly

HTH

Ollie Riches

"Mike P" <mi*******@gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have some login code that works fine on several local machines, but
always fails when uploaded. I think it has something to do with
encryption. Here is the Submit_Click event which when the code is
uploaded always sets newUser to null, so I always get 'Login failed'.
PhilePrincipal.ValidateLogin is called to set the value of newUser and
this involves encryption (see code below). That is the only reason I
can think of why it is not working. Any ideas?

private void Submit_Click(object sender, System.EventArgs e)
{
PhilePrincipal newUser = PhilePrincipal.ValidateLogin(
EmailAddress.Text, Password.Text );
if (newUser == null)
{
LoginResult.Text = "Login failed for " + EmailAddress.Text;
LoginResult.Visible = true;
}
else
{
Context.User = newUser;
FormsAuthentication.SetAuthCookie( EmailAddress.Text, true );
Response.Redirect("default.aspx");
}
}

public static PhilePrincipal ValidateLogin(string emailAddress, string
password)
{
Configuration.ModuleSettings moduleSettings =
Configuration.ModuleConfig.GetSettings();
int newID;
byte[] cryptPassword = EncryptPassword( password );

Data.User dataUser = new Data.User( moduleSettings.ConnectionString
);
if ( (newID = dataUser.ValidateLogin(emailAddress, cryptPassword)) >
-1 )
return new PhilePrincipal( newID );
else
return null;
}

public static byte[] EncryptPassword(string password)
{
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] hashBytes = encoding.GetBytes( password );
// compute SHA-1 hash.
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] cryptPassword = sha1.ComputeHash ( hashBytes );
return cryptPassword;
}
Cheers,

Mike


*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2

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

Similar topics

1
by: Mr_Ed | last post by:
Hi all, Ok this is a problem we have been having for quite a while and its finally coming to a head.... Ever since we have gone to a Windows 2000 server using IIS5 for our intranet we have had a...
0
by: Adam Fortuno KOVICK | last post by:
--Boundary_(ID_B/b4ffTtDNz/xCjv2UIigg) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline All, I've been attempting to assign a password...
0
by: Ed Ploy | last post by:
Would anyone care to point me to a good site or group for troubleshooting user .Net / Passport login problems? I've turned up a lot of development info (such as this group), but little on...
6
by: Andrew Chalk | last post by:
My application attempts to connect to an SQL Server database as name ASPNET and Login Name SERVERNAME/ASPNET in response to these commands: SqlConnection myConnection = new SqlConnection("Data...
0
by: clintonG | last post by:
I applied aspnet_regsql to SQL2K which was working fine throughout Beta 2 development. After installing Visual Studio and SQL Express RTM my application has blown up. Logging in to the application...
12
by: Michael | last post by:
Please Help me. I've got a .Net 2003 program that attaches to a SQL Server machine and I'm getting the above error when a user tries to log in. The SQL server is setup to use Windows Auth. and I...
7
by: PSorensen | last post by:
Hi Is there someone who know an easy way, so only one user can access a MS Access db without using users/groups in the database? It should be done by only knowing that someone is logged in/or...
2
by: mark4asp | last post by:
This is a simplified version of my site. There are Premium users who have access to the Premium directory. Anyone else attempting to access it should be logged and then redirected to the...
22
by: klenwell | last post by:
I'm in the process of refactoring the php code base I've amassed over the last few years into an object-oriented framework. I'm about to start in on the authentication/login extension and I've...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.