Solved

Why can't I use User.Identity.Name on a .master.vb file?

Posted on 2009-07-13
3
272 Views
Last Modified: 2012-05-07
I am making a job board for the college I attend.

When an employer first creates their account I need to have them fill in their profile as the first thing they do.  Creating a profile gives them an Employer ID from the database.  I need this in order to prevent them from creating a Job without first having an Employer ID which causes problems.

In order to do this I am disabling some links on the employer.master file based on the raw URL of the user.  Disabling links is no problem except for the fact that I need to have one enabled, the "Contact us for help" link.  If the new employer clicks this link, I need to check if they have already filled a profile and gotten their ID from the database (because this link is also available everywhere else in the site).  If they have not, I need to maintain the disabled status of the links previously disabled.

My idea was to use code like the following which works fine on other pages in the site for determining who the user is.

After executing that code I would check to see if Session("Emp_UserLogin") has a value.  If not, disable the links.

Any ideas?
Session("Emp_UserLogin") = User.Identity.Name
 

        Dim myConnectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CAC.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

        Using myConnection As New SqlConnection(myConnectionString)

            Dim myCommand As New SqlCommand()

            myCommand.Connection = myConnection

            myCommand.CommandText = "SELECT [EmpID] FROM [Employer] WHERE ([Emp_UserLogin] = '" & Session("Emp_UserLogin") & "')"

            myConnection.Open()

            Session("EmpID") = myCommand.ExecuteScalar()

        End Using

Open in new window

0
Comment
Question by:spaceneedlejumper
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
Espavo earned 500 total points
ID: 24842338
Use:
Session("Emp_UserLogin") = Page.User.Identity.Name
0
 

Author Comment

by:spaceneedlejumper
ID: 24843053
Thank you!
0
 

Author Closing Comment

by:spaceneedlejumper
ID: 31602932
I think I had this problem before when I wasn't paying for this service :)=
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now