IIdentity

IIdentity

Old forum URL: forums.lhotka.net/forums/t/105.aspx


Samg60 posted on Monday, May 15, 2006

I have just started using CSLA 2.0 and wish to use teh IIdentity and IPrincipal classes, however I wish to add a number of properties to the Identity Class such as Id, I have done this successfully however when i map Csla.ApplicationContext.User = principa none of these new properties are available, I appreciate this is becasue the IIdentity Interface doesnt expose these but any help would be welcome.

RockfordLhotka replied on Monday, May 15, 2006

You need to cast ApplicationContext.User to your specific type to get at your custom properties. This is always true when working with .NET principal objects, because they are always stored and manipulated as type IPrincipal (and IIdentity of course), and to get at custom enhancements casting is required.

Personally I tend to create a User class/module with Shared/static methods to abstract the whole thing. Then throughout my code I just do User.Name or User.Supervisor or whatever. The class looks kind of like this:

public static class User
{
  public static string Name
  {
    get { return ApplicationContext.User.Identity.Name; }
  }
  // etc.
}

guyroch replied on Monday, May 15, 2006

I also use a similar approach.  However, I have my own class that inherits from BusinessBase, let say MyBusinessBase.  I have all of that kind of "global" code into MyBusinessBase.  Then I sub-class _ALL_ of my classes from MyBusinessBase, _NOT_ BusinessBase directly.

Samg60 replied on Tuesday, May 16, 2006

thanks both of you although, I am new to all this and am a little lost, all I want to do is get the stored proc in my own IIdentity class to return things such as client Id etc, and then store these in a session so that they can be accesses by the .aspx pages.



Copyright (c) Marimer LLC