Question about location of a class in a WCF application

B

Bill Gower

I have a class called LWUser which contains the properties and methods that
represent a user of the system. This class sits in the Business Services
solutions on the server. I also have a class called LWUserUI which sits on
the client side in the Client solution. I am going to create a third class,
LoggedInUser, a singleton class, which holds information such as security
access, user info for the current logged in user. I am going to use a
singleton class as there can only be one user logged in and I need this
information throughout the app. Where should the class, LoggedInUser sit,
in the the UI solution on the client side or in the Business Services
solution on the server side?

Bill
 
N

Nicholas Paldino [.NET/C# MVP]

Bill,

Well, the answer to the question is where do you need it? I am curious
though, you can only have one user logged into your system at a time? Also,
what does this have to do with WCF? If you are using WCF then that implies
that you are running a service somewhere, and to have just one user be able
to access the service at a time kind of defeats the purpose.
 
M

Marc Gravell

On the server-side, a singleton user makes not-so-much sense. Perhaps
the correct answer here is that the user should be represented by the
"principal" on both the server and client (although probably different
implementations). This would allow you to use full role-based-security
throughout your code, and allow you (and other code) to use a fairly
standard way of asking "who am I?" and "what can I do?". Think of
LoggedInUser more as a static method acting on some property of the
current-thread (very comparable to Thread.CurrentPrincipal) and it
makes perfect sense to merge the two concepts.

I have implemented custom authentication and role (principal)
providers under WCF, so I know this approach can work.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top