PTIdentity and my own properties (MemberID)PTIdentity and my own properties (MemberID)
Old forum URL: forums.lhotka.net/forums/t/2136.aspx
ballistic posted on Friday, January 12, 2007
Hello,
I woud like to add a memberID to PTIdentity since I will be looking up members based on their ID, and not their username.
There is an "IIdentity" region in the PTIdentity.vb file, which is where I think I need to add my memberID property. However, I do not know if I'm suppose to match it up to the IIdentity interface. Rocky's 3 properties AuthType, IsAuth, and Name() all implement the interface:
Implements
System.Security.Principal.IIdentity.XXXXSo first off, I am not sure if I can add my own property.
Second, if I do, am I suppose to match it to a property in the interface.
And finally, how would I access this custom property from my library?
Thank you,
- Andy
RockfordLhotka replied on Friday, January 12, 2007
You can't alter IIdentity - that's a .NET interface. However, you can add your own public properties to your custom identity class - that's no problem.
The slight wrinkle to this, is that all the .NET API's return IIdentity, so you need to always cast the identity object to your custom identity type to get at your property, like:
x = CType(Csla.ApplicationContext.User.Identity, MyCustomIdentity).CustomProperty
fsjohn replied on Monday, February 23, 2009
Hi,
I am getting the following error:
Unable to cast object of type 'CSLA.Security.BusinessIdentity' to type 'MyCustomIdentity'.
Thanks
fsjohn replied on Thursday, March 05, 2009
Hi,
I am getting the following error:
Unable to cast object of type 'CSLA.Security.BusinessIdentity' to type 'MyCustomIdentity'.
Thanksrfcdejong replied on Thursday, March 05, 2009
fsjohn: Hi,
I am getting the following error:
Unable to cast object of type 'CSLA.Security.BusinessIdentity' to type 'MyCustomIdentity'.
Thanks
John,
U should post a new thread on this forum and in that thread explain exactly what goes wrong while debugging. Include a call stack and even better the code of your class.
Greetings,
Raymond de Jong
fsjohn replied on Tuesday, March 10, 2009
Hi Raymond,
thanks for getting back.
The Call Stack does not show anything, just the current call.
I noticed that even if I use the original class (PTIdentity) without adding any custom property, I am still unable to cast CSLA.Security.BusinessIdentity to type PTIdentity.
Cheers,
Omar
fsjohn replied on Tuesday, March 10, 2009
Hi,
ProjectTracker20vb Solution:
PTWin project:
Debug.Print(CType(Csla.ApplicationContext.User.Identity, Security.PTIdentity).Nick)
(While debugging Csla.ApplicationContext.User.Identity = {ProjectTracker.Library.Security.PTIdentity} before Casting)
Casting OK!!!
MySolution:
MyUserControl Project:
Debug.Print(CType(Csla.ApplicationContext.User.Identity,MyCompany.Security.MyIdentity).Name)
(While debugging Csla.ApplicationContext.User.Identity = {CSLA.Security.BusinessIdentity} before Casting)
Casting NO WORKING!!!
Do you know why I am getting Csla.ApplicationContext.User.Identity = {CSLA.Security.BusinessIdentity} instead of Csla.ApplicationContext.User.Identity = {MyCompany.Security.MyIdentity}
The Login is working properly:
Dim principal As New MyPrincipal(identity)
Csla.ApplicationContext.User = principal
At this point Csla.ApplicationContext.User.Identity = {MyCompany.Security.MyIdentity}
It seems Csla.ApplicationContext.User has changed somewhere.
Thanks,
Omar
fsjohn replied on Tuesday, March 10, 2009
I found the issue!!!
I am using CSLA1 and CSLA2 so when the user login I do both authentication, CSLA2 first and the CSLA1.
So my "last" CSLA.ApplicationContext.User was based on CSLA1.
Cheers...
rfcdejong replied on Tuesday, March 10, 2009
fsjohn: I found the issue!!!
I am using CSLA1 and CSLA2 so when the user login I do both authentication, CSLA2 first and the CSLA1.
So my "last" CSLA.ApplicationContext.User was based on CSLA1.
Cheers...
Great ;)
Copyright (c) Marimer LLC