Wednesday, October 21, 2009

Undocumented SQL pwdcompare function.

There will be some occasion, where we need to check SQL authentication programmatically, here is one SQL undocumented function pwdComapare, will return ‘1′ if password match with password hash in SQL server.


This SQL stuff will explains rest.

Declare @loginName as varchar(100)

Declare @Password as varchar(50)

set @loginname = ‘guna’

set @Password = ‘gunapwd123′

IF (select pwdcompare(@Password,Password_hash) from sys.sql_logins

where name = @loginName) = 1

Select ‘Success’

ELse

Select ‘Failure’

No comments:

Post a Comment