Showing posts with label login. Show all posts
Showing posts with label login. Show all posts

Friday, March 23, 2012

help with a stored procedure

here is my sp

create proc [login]

(

@.email as varchar(200)

@.password as varchar(200)

)

as

begin

select customerid from customerlogin

where email = @.email

and password = @.password

End

print 'Welcome'

print (@.email)

End

This works fine, but if the email is wrong, what do I need to add to this to print that the email is wrong and not print 'welcome email'

Help, please.....

Hello,

I think what you want is:

create proc [login]

(

@.email as varchar(200)

@.password as varchar(200)

)

as

IF EXISTS (select customerid from customerlogin where email = @.email and password = @.password)

BEGIN

print 'Welcome'

print (@.email)

END

ELSE

BEGIN

print 'Bad login!'

print (@.email)

END

GO

As a side note, best practice is to NOT pass the users' password, but rather store a hash of the password and then when the user attempts to login, you simply create a hash of the entered password and compare it with the hashed value stored in the db.

Cheers

Rob

|||

create procedure sp_login

@.email as varchar(200)

@.password as varchar(200)

AS

Select CASE WHEN ((Select COUNT(*) from customerlogin where email = @.email and password = @.password) = 0)

THEN Print 'Invalid Login'

ELSE Print 'Welcome ' + @.email

END AS [EmailTest]

Adamus

Wednesday, March 7, 2012

Help Tracking down failed SQL login

On my SQL 2000 Server and in my application event log I
am getting numerous event id of 17055, which is a login
failure for a particular account on my SQL server. The
problem I am having is that I am trying to find out where
this account is logging in from. The description of the
event reads: 18456 :Login failed for user 'user'. Is
there a logging mode or tool I can use to find out where
this login is being generated from so I can fix this
failed login attempt?
Thanks,
Alex
Alex,
Check the SQL Profiler tool that comes with SQL Server so you already have
it.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com
"Alex Mook" <anonymous@.discussions.microsoft.com> wrote in message
news:aec401c436af$405d75a0$a001280a@.phx.gbl...
> On my SQL 2000 Server and in my application event log I
> am getting numerous event id of 17055, which is a login
> failure for a particular account on my SQL server. The
> problem I am having is that I am trying to find out where
> this account is logging in from. The description of the
> event reads: 18456 :Login failed for user 'user'. Is
> there a logging mode or tool I can use to find out where
> this login is being generated from so I can fix this
> failed login attempt?
> Thanks,
> Alex

Help Tracking down failed SQL login

On my SQL 2000 Server and in my application event log I
am getting numerous event id of 17055, which is a login
failure for a particular account on my SQL server. The
problem I am having is that I am trying to find out where
this account is logging in from. The description of the
event reads: 18456 :Login failed for user 'user'. Is
there a logging mode or tool I can use to find out where
this login is being generated from so I can fix this
failed login attempt?
Thanks,
Alex
Alex,
have a look at profiler for this - you can to pick up the "Host Name" this
way using the AuditLogin... events.
Regards,
Paul Ibison
|||Try making a network capture while the problem is occuring. This will give
you the mac address and IP address of the client.
Microsoft Network Monitor is included in Windows 2000 Server.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.

Help Tracking down failed SQL login

On my SQL 2000 Server and in my application event log I
am getting numerous event id of 17055, which is a login
failure for a particular account on my SQL server. The
problem I am having is that I am trying to find out where
this account is logging in from. The description of the
event reads: 18456 :Login failed for user 'user'. Is
there a logging mode or tool I can use to find out where
this login is being generated from so I can fix this
failed login attempt?
Thanks,
AlexAlex,
have a look at profiler for this - you can to pick up the "Host Name" this
way using the AuditLogin... events.
Regards,
Paul Ibison|||Try making a network capture while the problem is occuring. This will give
you the mac address and IP address of the client.
Microsoft Network Monitor is included in Windows 2000 Server.
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.