473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

windows authentication and putting queried data into session state

Hi everyone,

I searched for this but with little luck. I'm working on a project and
need to do the following:
1. have a user authenticate to an ASP.net site using windows
authentication
2. take either HttpContext.User or HttpContext.Current.User as the
parameter for a stored procedure that will draw some simple data on
that user.
3. put those bits of data into session (just a handful of fields,
nothing big).
4. then use that session data for prepopulating forms, pulling up
relevant data and navigation, etc.

I will use security settings from IIS to control access to particular
directories or files, but wondered if this is a smart way to do it?
Any big security risks? I want to capitalize on about 200 users
already having active directory accounts, but favor using session to
hold data that AD doesn't have in it.

Any suggestions? What would that query look like (from #2 above)?

thanks,
NEM

Mar 19 '07 #1
1 1335
On Mar 19, 7:28 am, nem.use...@gmail.com wrote:
Hi everyone,

I searched for this but with little luck. I'm working on a project and
need to do the following:
1. have a user authenticate to an ASP.net site using windows
authentication
2. take either HttpContext.User or HttpContext.Current.User as the
parameter for a stored procedure that will draw some simple data on
that user.
3. put those bits of data into session (just a handful of fields,
nothing big).
4. then use that session data for prepopulating forms, pulling up
relevant data and navigation, etc.

I will use security settings from IIS to control access to particular
directories or files, but wondered if this is a smart way to do it?
Any big security risks? I want to capitalize on about 200 users
already having active directory accounts, but favor using session to
hold data that AD doesn't have in it.

Any suggestions? What would that query look like (from #2 above)?

thanks,
NEM
In your web.config file you would be using
<system.web>
<authentication mode="Windows">
</system.web>

To get the username you would use the following code:
HttpContext.Current.User.Identity.Name

What I have done in the past is to create my own CustomUser class that
takes care of that for me. So you would have properties for all of
the various things you are storing in the database (first name, last
name, email, birthdate, etc). Then I would have a constructor with no
parameters that grabs the username from the current context (as above)
and then calls a stored procedure that would return the information
and set all of the properties of the object.

That way you still use an object to store your user information
keeping it all in one tightly bundled place instead of using
Session["userFirstName"], Session["userLastName"], etc. You can still
store the CustomUser object in Session so that you don't ahve to hit
up the database every page.

Hope that helps.

Mar 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Andrew | last post by:
Hey all, I would like to preface my question by stating I am still learning ASP.net and while I am confident in the basics and foundation, the more advanced stuff is still a challenge. Ok....
1
by: Ben S | last post by:
we have a webapp using form authentication, and the time out is set at 120 minutes, so whenever a session is idle for > 120 minutes or so, it will make the user sign in again. This seems to be...
3
by: Joe Fallon | last post by:
I use Forms authentication and State Server and Cookies are enabled. Is this correct? If the session is set to timeout in 20 minutes that means that if there is no activity for 20 minutes then...
11
by: xenophon | last post by:
I have a web site with forms authentication and a single logon page. I have 4 subdirectories, each that should be protected by a different username/password combination. For testing purposes, the...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
2
by: Randall Parker | last post by:
Some questions on forms authentication: 1) Can one do one's own checking of username and password and totally bypass calling FormsAuthentication.Authenticate? 2) does the "new...
1
by: Mark Olbert | last post by:
I'm building an ASPNET2 website which uses forms authentication but does not use the Microsoft-supplied membership providers (mostly because I don't want to create my own provider at this point, and...
14
by: tshad | last post by:
I am trying to set up an intranet at work that will use our Active directory to authorize our users. We also want them to access the site from the outside (such as at home) and also be...
8
by: Tomasz | last post by:
Hello Developers! I have an interesting problem using my custom MembershipProvider, RoleProvider and Forms Authentication. Both MembershipProvider and RoleProvider require session state, where...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.