[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.security

Re: Custom Authentication Ticket

Shawn Jackson

7/8/2003 4:19:00 PM

James, I found your C code and tutorial about this. I attempted to
convert it to VB as follows but could you possibly tell me why the code
segment 'ActiveUserInfoSerializer.Deserialize' gives the error
"Reference to non-shared member requires an object reference"? Is there
a difference between C and VB that accounts for this? In your article
http://www.dotnetcoders.com/web/Articles/ShowArticle.aspx?... You
describe 3 classes. Should they be in three separate class files or
what? I have been away from OO programming for a few years and it isn't
natural to me currently. Thanks.

Public Class ActiveUserInfo

Dim UserID As Integer
Dim Username As String
Dim UserType As String

End Class

Imports System
Imports System.IO
Imports System.Xml.Serialization
Imports System.Web


Public Class ActiveUserInfoSerializer

Public Function Serialize(ByVal objData As ActiveUserInfo) As String

Dim sw As StringWriter = New StringWriter()
Dim serializer As XmlSerializer = New XmlSerializer(objData.GetType())

serializer.Serialize(sw, objData)
sw.Close()
Serialize = sw.ToString()

End Function

Public Function Deserialize(ByVal strXML As String) As ActiveUserInfo

Dim type1 As ActiveUserInfo
Dim sr As StringReader = New StringReader(strXML)
Dim serializer As XmlSerializer = New XmlSerializer(type1.GetType)
Dim objDeserializedObject As ActiveUserInfo =
CType(serializer.Deserialize(sr), ActiveUserInfo)

Deserialize = objDeserializedObject

End Function

End Class

Public Class ActiveUser

Public ReadOnly Property UserID() As Integer
Get
Dim objActiveUser As ActiveUser =
ActiveUserInfoSerializer.Deserialize(HttpContext.Current.User.Identity.N
ame)
UserID = objActiveUser.UserID
End Get
End Property

Public ReadOnly Property UserName() As String
Get
Dim objActiveUser As ActiveUser =
ActiveUserInfoSerializer.Deserialize(HttpContext.Current.User.Identity.N
ame)
UserName = objActiveUser.UserName
End Get
End Property

Public ReadOnly Property UserType() As String
Get
Dim objActiveUser As ActiveUser =
ActiveUserInfoSerializer.Deserialize(HttpContext.Current.User.Identity.N
ame)
UserType = objActiveUser.UserType
End Get
End Property

End Class




*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!