July 7, 2009 at 10:32 pm
DECLARE @user-id INT
DECLARE @PassWord VARCHAR(50)
DECLARE @Ok INT
SET @user-id = 101
SET @PassWord = 'dgHH%Ggt4['
SET @Ok = 0
SET @Ok = (SELECT COUNT(*) WHERE 101 = @user-id
AND 'dgHH%Ggt4[' = LTRIM(RTRIM(@PassWord)) COLLATE SQL_Latin1_General_Cp1_CS_AS)
PRINT @Ok
if PRINT = 1 it seams to sugest a correct test of a password that
1) Character correct
2) Case sensitive correct.
Is the best and most TSQL accurate way to check a password for the above strict conditions.
Any other methods ???
July 8, 2009 at 12:36 am
No need to invoke SELECTs.
IF @user-id = 101 AND @Password = 'dgHH%Ggt4[' COLLATE SQL_Latin1_General_Cp1_CS_AS
PRINT 'Ok!'
ELSE
PRINT 'False'
But I doubt this is your real scenario. You do have a table where the UserID and Password is stored, right?
N 56°04'39.16"
E 12°55'05.25"
July 8, 2009 at 6:35 am
In that case, there is no need to specify the collation,
COLLATE SQL_Latin1_General_Cp1_CS_AS
correct me, If am wrong in my views.
Thanks,
Venkatesan Prabu .J
Thanks and Regards,
Venkatesan Prabu, 😛
My Blog:
http://venkattechnicalblog.blogspot.com/
July 8, 2009 at 1:46 pm
You do have a table where the UserID and Password is stored, right?
Yes thats is correct, all is an table. So the consensus is that my SQL is correct and the best way to achieve a password check ??
July 8, 2009 at 1:46 pm
You do have a table where the UserID and Password is stored, right?
Yes thats is correct, all is an table. So the consensus is that my SQL is correct and the best way to achieve a password check ??
July 8, 2009 at 1:47 pm
You do have a table where the UserID and Password is stored, right?
Yes thats is correct, all is an table. So the consensus is that my SQL is correct and the best way to achieve a password check ??
July 8, 2009 at 1:47 pm
You do have a table where the UserID and Password is stored, right?
Yes thats is correct, all is an table. So the consensus is that my SQL is correct and the best way to achieve a password check ??
July 8, 2009 at 2:34 pm
If you ever have to "store passwords" make sure you salt and hash them.
July 8, 2009 at 5:12 pm
this code looks goog to me:
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply