log in function

ilyail3

Active member
Joined
Feb 15, 2005
Messages
31
Programming Experience
1-3
I want to build a T-SQL function on my database server that will get the
parameters user_name,password and return a boolean value if such a user
exist in the table Users. What kind of function I need and what should it look
like?
 
Hi Guys,

I want to build on this if possible - I have an employee table with a list of all the employees needed within the program I am building, but only a certain amount of them need to be able to access the system.
Instead of creating another table with the same data in, I want to use this employee table and add a new password field for the users. Because some of the employees in this table won't be accessing the database, they won't have a password. But that's now a security issue as on the log-on form, you could enter one of these names, leave the password blank, and get access to the system.

I'm thinking along the lines of adding another field to the table, 0 for no access, 1 for access, so I need a hand with altering the SP to take this in account, is it as simple as;

WHERE (Username LIKE @Username) AND (Password LIKE @Password) AND (AccessRights=1)

So if the accessright in the table is 0, then the system will still take the name and the blank password, but fall over on the access rights level?

Thanks for your help
Luke
 
Not to worry, I seem to have talked myself to do it! Exactly as what was said above, heres the syntax;

CREATE PROCEDURE sp_getusers
(
@Username text,
@Password text,
@Rowcount int output
)
AS
SELECT EmployeeName, Password
FROM Employee
WHERE (EmployeeName LIKE @Username) AND (Password LIKE @Password) AND (AccessRights = 1)
SELECT @Rowcount = @@rowcount
RETURN

Thanks anyway for the help - keep up the good work.
 
Glad to see that you taught yourself, much better then being spoon feed. As the saying goes, you can catch a fish for a man and he'll live for a day, teach a man to fish and he'll live for a lifetime.
 
Back
Top