Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need to check for User ID to grant access

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2008-10-27 : 15:18:16
Hi Group:

I am working in a Web that checks for User ID to grant access view.
We have one sql Table that contain the following Columns.

FirstName-----LastName -----UserID------Application_Name-----
John Smith jsmith Oracle
Juliet Robertson jroberson Oracle

etc..etc...

I have the following code that
    lblUser.Text = (Request.ServerVariables("AUTH_USER"))
Session("strUser") = lblUser.Text


[code] If Session("strUser") <> "to the USERID from the Table" Then
Response.Redirect("Security.aspx")----Access Denied
Exit Sub
End If


I need to create stored Procedure in SQL that checks for matching USERID = Session("strUser")

Thank You for your help.



clarkbaker1964
Constraint Violating Yak Guru

428 Posts

Posted - 2008-10-27 : 20:44:23
This would go in the database where you need to check for the user name.


create procedure usp_ValidateUser
(
@UserId varchar(255)
)
as
if exists(select 1 from sys.sysusers where Name = @UserId)
begin
select 1 as ValidUser
end
else
begin
select 0 as ValidUser
end



You can do anything at www.zombo.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-28 : 00:07:01
you can use your table instead of sysusers table in above code to check also.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-10-28 : 03:50:59
quote:
Originally posted by osirisa

Hi Group:

I am working in a Web that checks for User ID to grant access view.
We have one sql Table that contain the following Columns.

FirstName-----LastName -----UserID------Application_Name-----
John Smith jsmith Oracle
Juliet Robertson jroberson Oracle

etc..etc...

I have the following code that
    lblUser.Text = (Request.ServerVariables("AUTH_USER"))
Session("strUser") = lblUser.Text


[code] If Session("strUser") <> "to the USERID from the Table" Then
Response.Redirect("Security.aspx")----Access Denied
Exit Sub
End If


I need to create stored Procedure in SQL that checks for matching USERID = Session("strUser")

Thank You for your help.







If i do understand you properly, this can be better implemented in .net's memberships. readup on User roles
Go to Top of Page
   

- Advertisement -