473,549 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

validating a password string

i am storing a usernames and passwords in a table called Users.

I present a login form to the user when my application starts up
(VB.NET, .NET CF, Windows Mobile 5)

The user chooses a username from a combo box that queries the Users
table. Then they type in a password string.

I then use the following code to validate the string when the user
clicks on the Submit menu item

Private Sub Submit_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Submit.Click
vUserName = Me.UserCombo.Te xt 'set variable for use later in
the app
'MsgBox(vUserNa me)

Dim vPassword2 As String
vPassword2 =
CStr(Me.UsersTa bleAdapter.GetP assword(UserDat aSet.Users, vUserName))
'MsgBox(vPasswo rd2)

If vPassword2 <Me.UserPasswor d.Text Then
MessageBox.Show ("Login Failed. Please try again.",
"Login", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation,
MessageBoxDefau ltButton.Button 1)
'refill the username list with all options
Me.UsersTableAd apter.Fill(User DataSet.Users)
Else
Dim frmMainMenu As New SystemMenu 'create the system menu
class
frmMainMenu.Sho w()

End If
End Sub

I am not able to get this to compare and validate the password string.
any advice, comments or experience would be most appreciated.

Ryan

Aug 23 '07 #1
4 2588
ryan,

Why are you using passwords (assuming that it is for a window application)
and not the integrated windows validation?

http://msdn2.microsoft.com/en-us/lib...principal.aspx

Cor

"ryan" <ry********@gma il.comschreef in bericht
news:11******** **************@ i13g2000prf.goo glegroups.com.. .
>i am storing a usernames and passwords in a table called Users.

I present a login form to the user when my application starts up
(VB.NET, .NET CF, Windows Mobile 5)

The user chooses a username from a combo box that queries the Users
table. Then they type in a password string.

I then use the following code to validate the string when the user
clicks on the Submit menu item

Private Sub Submit_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Submit.Click
vUserName = Me.UserCombo.Te xt 'set variable for use later in
the app
'MsgBox(vUserNa me)

Dim vPassword2 As String
vPassword2 =
CStr(Me.UsersTa bleAdapter.GetP assword(UserDat aSet.Users, vUserName))
'MsgBox(vPasswo rd2)

If vPassword2 <Me.UserPasswor d.Text Then
MessageBox.Show ("Login Failed. Please try again.",
"Login", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation,
MessageBoxDefau ltButton.Button 1)
'refill the username list with all options
Me.UsersTableAd apter.Fill(User DataSet.Users)
Else
Dim frmMainMenu As New SystemMenu 'create the system menu
class
frmMainMenu.Sho w()

End If
End Sub

I am not able to get this to compare and validate the password string.
any advice, comments or experience would be most appreciated.

Ryan
Aug 24 '07 #2
Cor

Thanks for responding. This application is a commercial windows mobile
app that is sync'ed with a desktop client / SQL. The end user can set
up in the desktop app user profiles, names, passwords, and roles
specific to the application.

I actually got it to work with a revision to my code:

Private Sub Submit_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Submit.Click
vUserName = Me.UserCombo.Te xt 'set variable for use later in
the app
'MsgBox(vUserNa me)

Me.UsersTableAd apter.GetPasswo rd(UserDataSet. Users, vUserName)

Dim vPassword1 As String
Dim vPassword2 As String
Dim compare As StringCompariso n
Dim i As Boolean

vPassword1 = Me.hiddenpasswo rd.Text

vPassword2 = Me.UserPassword .Text
'MsgBox(vPasswo rd2)

i = String.Equals(v Password1, vPassword2, compare)

If i = False Then
MessageBox.Show ("Login Failed. Please try again.",
"Login", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation,
MessageBoxDefau ltButton.Button 1)
'refill the username list with all options
Me.UsersTableAd apter.Fill(User DataSet.Users)
Else
Dim frmMainMenu As New SystemMenu 'create the system menu
class
frmMainMenu.Sho w()

End If
End Sub

I am fairly new to VB.net so any feedback would be appreciated!!!

Ryan

On Aug 23, 10:45 pm, "Cor Ligthert[MVP]" <notmyfirstn... @planet.nl>
wrote:
ryan,

Why are you using passwords (assuming that it is for a window application)
and not the integrated windows validation?

http://msdn2.microsoft.com/en-us/lib...y.principal.wi...

Cor

"ryan" <ryansyt...@gma il.comschreef in berichtnews:11* *************** ******@i13g2000 prf.googlegroup s.com...
i am storing a usernames and passwords in a table called Users.
I present a login form to the user when my application starts up
(VB.NET, .NET CF, Windows Mobile 5)
The user chooses a username from a combo box that queries the Users
table. Then they type in a password string.
I then use the following code to validate the string when the user
clicks on the Submit menu item
Private Sub Submit_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles Submit.Click
vUserName = Me.UserCombo.Te xt 'set variable for use later in
the app
'MsgBox(vUserNa me)
Dim vPassword2 As String
vPassword2 =
CStr(Me.UsersTa bleAdapter.GetP assword(UserDat aSet.Users, vUserName))
'MsgBox(vPasswo rd2)
If vPassword2 <Me.UserPasswor d.Text Then
MessageBox.Show ("Login Failed. Please try again.",
"Login", MessageBoxButto ns.OK, MessageBoxIcon. Exclamation,
MessageBoxDefau ltButton.Button 1)
'refill the username list with all options
Me.UsersTableAd apter.Fill(User DataSet.Users)
Else
Dim frmMainMenu As New SystemMenu 'create the system menu
class
frmMainMenu.Sho w()
End If
End Sub
I am not able to get this to compare and validate the password string.
any advice, comments or experience would be most appreciated.
Ryan- Hide quoted text -

- Show quoted text -

Aug 24 '07 #3
ryan wrote:
I am not able to get this to compare and validate the password string.
any advice, comments or experience would be most appreciated.
(1) Don't retrieve the password to compare it. Just ask the database to
count the User records where the username and password are the ones
entered. If you count comes back as 1, all is well.

(2) Don't even store passwords!
Get hold of a [one-way] encryption routine, use that in the client
application and store/compare the encrypted version.

That way, if anyone steals your database or tries to intercept the
network traffic, they don't get anything useful.

HTH,
Phill W.
Aug 24 '07 #4
On Aug 24, 11:28 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-
kwrote:
ryan wrote:
I am not able to get this to compare and validate the password string.
any advice, comments or experience would be most appreciated.
thanks Phil

I will do that!

Ryan
(1) Don't retrieve the password to compare it. Just ask the database to
count the User records where the username and password are the ones
entered. If you count comes back as 1, all is well.

(2) Don't even store passwords!
Get hold of a [one-way] encryption routine, use that in the client
application and store/compare the encrypted version.

That way, if anyone steals your database or tries to intercept the
network traffic, they don't get anything useful.

HTH,
Phill W.

Aug 24 '07 #5

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

Similar topics

4
3193
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a password (plain text): 1) Validate that the password is correct for that user *without actually logging in*. 2) If the password is valid, return a...
2
3927
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\ You selected the file named AAA.XML getXmlAlgorithmDocument(): IOException Not logged in
2
2112
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating event, I check that the string in the textbox is a file that exists or whether or not the string is blank and display a message box in either case. I...
0
1067
by: krisk | last post by:
I have a question or two regarding local users and groups. I have an ASP.NET 2.0 (C#) application (intranet-based, not on the Internet), and, on one of the pages, I have two textboxes for end-users to enter a user name and password. The user name needs to be an actual user that is on the local computer, and the password (obviously) needs to...
1
3321
by: Raghu | last post by:
I have following code that validates a given user credentails against a active directory. The login part works but I can not search as it fails to return the record. Does any one have any idea what is wrong? public void Login(string user, string pwd, string domain) { string path = "<<my ldap path>>"; DirectoryEntry domainEntry = new...
0
1607
by: mk397 | last post by:
Hello, I'm new to this site and after reading through many posts decided to join. I have a problem with my basic login page. After I type in the login info I get the following error: Unspecified error Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more...
0
2098
by: sathyakvani | last post by:
hi al i wrote a code (LOgin form) that checks the user id and if it exists validates the password but this is not all validating and simply displaying user does not exist i am sending the code pls check and fix it pls its urgent using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing;
1
3784
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I've noticed that controls do not raise a Validating event if they are contained in a ToolStripDropDown via a ToolStripControlHost item. Please run the following sample and follow the instructions on the form to reproduce this issue: ------------------------------------ Public Class Form1 Inherits Windows.Forms.Form
6
1342
by: phpmagesh | last post by:
Hi I am creating login page with validation. i have index.php page with login box, for validating this login detail i m redirecting to login_validate.php. Login_validate.php file code: <?php
0
7524
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7475
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6048
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5372
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.