473,396 Members | 2,129 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.

Universal "Session" Functionality?

I'm currently creating an application with an n-tier design(not separate
boxes for each layer, just separation of pres/logic/data) that will have
both a web and windows interface. I'm trying to find out if there is a way
to maintain user information and access it in either my business logic or
data layer, without having to pass some custom object around that contains
the information.

For the web there's of course the Session, or preferably the
User(implementing IPrincipal), but I can't figure out what there is for a
WinForms app, or just something in general I can access in a class library
that isn't directly tied to either application.

If someone could give me some information on how I can access IPrincipal
information uniformly it would be most appreciated.

Thanks,
Steve
Nov 15 '05 #1
6 1271
Steve, how about creating your own session class and storing the state in a
database? Once you have that you can access it through both the web app and
the WinForm as long as you have access to the DB. You'll pay a performance
penalty for teh flexibility but there are many situations where it is worth
it.

--
Greg Ewing [MVP]
http://www.citidc.com
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:un*************@TK2MSFTNGP11.phx.gbl...
I'm currently creating an application with an n-tier design(not separate
boxes for each layer, just separation of pres/logic/data) that will have
both a web and windows interface. I'm trying to find out if there is a way
to maintain user information and access it in either my business logic or
data layer, without having to pass some custom object around that contains
the information.

For the web there's of course the Session, or preferably the
User(implementing IPrincipal), but I can't figure out what there is for a
WinForms app, or just something in general I can access in a class library
that isn't directly tied to either application.

If someone could give me some information on how I can access IPrincipal
information uniformly it would be most appreciated.

Thanks,
Steve

Nov 15 '05 #2
That's pretty much what I wanted to avoid. One of the primary reasons for
maintaining this information for the user would be to retain their
connection string, which is set at login. Storing it in the DB would mean
two hits for each DB action. I'm surprised MS didn't implement something
like this for however a .Net application is run.

Steve

"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
Steve, how about creating your own session class and storing the state in a database? Once you have that you can access it through both the web app and the WinForm as long as you have access to the DB. You'll pay a performance penalty for teh flexibility but there are many situations where it is worth it.

--
Greg Ewing [MVP]
http://www.citidc.com

Nov 15 '05 #3
how about a file then, disk or memory file can do. You said you didn't want
to pass objects around but that's the next best thing if you want to avoid
the database hit.

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/2bz4t
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:uF**************@TK2MSFTNGP11.phx.gbl...
That's pretty much what I wanted to avoid. One of the primary reasons for
maintaining this information for the user would be to retain their
connection string, which is set at login. Storing it in the DB would mean
two hits for each DB action. I'm surprised MS didn't implement something
like this for however a .Net application is run.

Steve

"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
Steve, how about creating your own session class and storing the state
in a
database? Once you have that you can access it through both the web app

and
the WinForm as long as you have access to the DB. You'll pay a

performance
penalty for teh flexibility but there are many situations where it is

worth
it.

--
Greg Ewing [MVP]
http://www.citidc.com


Nov 15 '05 #4
Steve, are you on an Active Directory domain or have access to an LDAP
server? I've had great success putting user db connection strings in AD.
It's optimized for read so it's very fast. If you have to do a lot of
updates I'd probably go with the DB.

--
Greg Ewing [MVP]
http://www.citidc.com
"Alvin Bruney" <vapor at steaming post office> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
how about a file then, disk or memory file can do. You said you didn't want to pass objects around but that's the next best thing if you want to avoid
the database hit.

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/2bz4t
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:uF**************@TK2MSFTNGP11.phx.gbl...
That's pretty much what I wanted to avoid. One of the primary reasons for maintaining this information for the user would be to retain their
connection string, which is set at login. Storing it in the DB would mean two hits for each DB action. I'm surprised MS didn't implement something
like this for however a .Net application is run.

Steve

"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
Steve, how about creating your own session class and storing the state in
a
database? Once you have that you can access it through both the web

app and
the WinForm as long as you have access to the DB. You'll pay a

performance
penalty for teh flexibility but there are many situations where it is

worth
it.

--
Greg Ewing [MVP]
http://www.citidc.com



Nov 15 '05 #5
No, I don't at the moment(depending on growth there may be soon though). I'm
not sure how much that would help though. I'm doing SQL Authentication(to
users in in broad groups(end-users, resellers, etc...)), rather than
Windows. So would that mean that I would have to create a new user in AD for
each user of the system? If I did, how would I go about getting the
connection string info without passing data through to all of the necessary
functions? Is the user credential information somehow contained on the
current thread or some such?

Thanks,
Steve

"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:uf**************@TK2MSFTNGP10.phx.gbl...
Steve, are you on an Active Directory domain or have access to an LDAP
server? I've had great success putting user db connection strings in AD.
It's optimized for read so it's very fast. If you have to do a lot of
updates I'd probably go with the DB.

--
Greg Ewing [MVP]
http://www.citidc.com
"Alvin Bruney" <vapor at steaming post office> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
how about a file then, disk or memory file can do. You said you didn't

want
to pass objects around but that's the next best thing if you want to avoid
the database hit.

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/2bz4t
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:uF**************@TK2MSFTNGP11.phx.gbl...
That's pretty much what I wanted to avoid. One of the primary reasons for maintaining this information for the user would be to retain their
connection string, which is set at login. Storing it in the DB would mean two hits for each DB action. I'm surprised MS didn't implement something like this for however a .Net application is run.

Steve

"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
> Steve, how about creating your own session class and storing the state in
a
> database? Once you have that you can access it through both the web app and
> the WinForm as long as you have access to the DB. You'll pay a
performance
> penalty for teh flexibility but there are many situations where it

is worth
> it.
>
> --
> Greg Ewing [MVP]
> http://www.citidc.com



Nov 15 '05 #6
Steve, if you are using a Windows app or a web app which requires NT
authentication then yes, it is on the current thread. I don't remember the
properties off the top of my head but look in the System.Security namespace.
There should be properties like CurrentUser, WindowsPrincipal, or something
like that. If your web app uses anonymous access then you will only have
whatever user your WebApp runs under (ASPNET by default).

--
Greg Ewing [MVP]
http://www.citidc.com
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...
No, I don't at the moment(depending on growth there may be soon though). I'm not sure how much that would help though. I'm doing SQL Authentication(to
users in in broad groups(end-users, resellers, etc...)), rather than
Windows. So would that mean that I would have to create a new user in AD for each user of the system? If I did, how would I go about getting the
connection string info without passing data through to all of the necessary functions? Is the user credential information somehow contained on the
current thread or some such?

Thanks,
Steve

"Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
news:uf**************@TK2MSFTNGP10.phx.gbl...
Steve, are you on an Active Directory domain or have access to an LDAP
server? I've had great success putting user db connection strings in AD.
It's optimized for read so it's very fast. If you have to do a lot of
updates I'd probably go with the DB.

--
Greg Ewing [MVP]
http://www.citidc.com
"Alvin Bruney" <vapor at steaming post office> wrote in message
news:Oq**************@TK2MSFTNGP10.phx.gbl...
how about a file then, disk or memory file can do. You said you didn't

want
to pass objects around but that's the next best thing if you want to avoid the database hit.

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/2bz4t
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:uF**************@TK2MSFTNGP11.phx.gbl...
> That's pretty much what I wanted to avoid. One of the primary
reasons for
> maintaining this information for the user would be to retain their
> connection string, which is set at login. Storing it in the DB would

mean
> two hits for each DB action. I'm surprised MS didn't implement something > like this for however a .Net application is run.
>
> Steve
>
> "Greg Ewing [MVP]" <gewing@_NO_SPAM_gewing.com> wrote in message
> news:uY**************@TK2MSFTNGP12.phx.gbl...
> > Steve, how about creating your own session class and storing the state in
> a
> > database? Once you have that you can access it through both the
web app
> and
> > the WinForm as long as you have access to the DB. You'll pay a
> performance
> > penalty for teh flexibility but there are many situations where it

is > worth
> > it.
> >
> > --
> > Greg Ewing [MVP]
> > http://www.citidc.com
>
>



Nov 15 '05 #7

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

Similar topics

8
by: TWACS | last post by:
How do I add and get session defined variables? when I do this Session("USERID") = "NAME"; I get System.Web.UI.Page.Session' denotes a 'property' where a 'method' was expected Thanks,
9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
13
by: dee | last post by:
Hi My code complies the following line: Session("passed") = 1 but puts wiggly error line under the second Session("passed") in the following expression: Session("passed") = Session("passed") +...
10
by: thomson | last post by:
Hi, i create a session variable in C# as follows Session , but iam not able to access the variable in VB.net like intmode=Session("var"); Why is that ? Regards
4
by: R.A.M. | last post by:
Hello, I am writing ASP.NET application in which I need to use User Profiles and Session mechanisms. Here I include part of my source code (Admin.cs): using System; using System.Data; using...
10
by: Kurda Yon | last post by:
Hi, I set the register_globals off and try to get my code working under the new conditions. I stuck on the following problem: Warning: Unknown(): Your script possibly relies on a session side-...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.