Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 100
  • Last Modified:

Restrict access so only users whos userid begins with "u" are able to access the web page

I am able to pull user information as folks access my web page on the intranet. I have a page I want to restrict access to so that only those that have a userid that starts with the letter "u" are able to open it. What is the easiest way to do that.
0
jlcannon
Asked:
jlcannon
  • 5
  • 4
2 Solutions
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
if userID is a variable, you can do something like this:

if Lower( Left( userID, 1 ) ) = "u" then
      '-- user has access
else
       '-- user doesn't have access, maybe do a redirect to another page
       Response.Redirect "someOtherPage.asp"
end if
1
 
jlcannonAuthor Commented:
I am getting the following error using the above code:

Type mismatch: 'Lower'
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
sorry, Lower should be LCase, brain fart there. also, if userID is blank or null, you'll get an error, so if thats a possibility, make sure you check for it
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
jlcannonAuthor Commented:
Ok now I am trying to work out this error:

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content

I have gone as far as moving everything to before the HTML tag but still get this error.

   <%
Response.Buffer = True
%>
			<%
			
			if LCase( Left( vUID, 1 ) ) = "u" then
                    '-- user has access
                    Response.Clear
                    Response.Redirect "EffDash.asp"
                    
        Response.End
          
 end if %>

Open in new window

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
the code you have will redirect if the userID begins with the letter "u", is that what you want?

there is no error listed above...
0
 
jlcannonAuthor Commented:
yes that is what I want but if I try to use the code as in your response using the LCase if statement I get the error

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
remove the line

Response.Clear
0
 
jlcannonAuthor Commented:
Thank you!
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
glad to help :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now