Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Microsoft.VisualBasic
- Imports System.Data
- Public Class objUser : Inherits objAgent : Implements IContact
- Private Const DEF_REMOTEIP As String = ""
- Private Const DEF_PRIVLEVEL As Integer = 0
- Private Const DEF_ROLE As Integer = -1
- Private Const DEF_USERNAME As String = ""
- Private Const DEF_PASSWORD As String = ""
- Private Const DEF_AUTHENTICATED As Boolean = False
- Private _sessionID As Guid = Nothing
- Private _remoteIP As String = DEF_REMOTEIP
- Private _privLevel As Integer = DEF_PRIVLEVEL
- Private _roles As New ArrayList
- Private _username As String = DEF_USERNAME
- Private _password As String = DEF_PASSWORD
- Private _authenticated As Boolean = DEF_AUTHENTICATED
- ' Properties
- Public Property SessionID() As Guid
- Get
- Return _sessionID
- End Get
- Set(ByVal value As Guid)
- _sessionID = value
- End Set
- End Property
- Public Property RemoteIP() As String
- Get
- Return _remoteIP
- End Get
- Set(ByVal value As String)
- _remoteIP = value
- End Set
- End Property
- Public Property Priv() As Integer
- Get
- Return _privLevel
- End Get
- Set(ByVal value As Integer)
- _privLevel = value
- End Set
- End Property
- Public Property Roles() As ArrayList
- Get
- Return _roles
- End Get
- Set(ByVal value As ArrayList)
- _roles = value
- End Set
- End Property
- Public Property Username() As String
- Get
- Return _username
- End Get
- Set(ByVal value As String)
- _username = value
- End Set
- End Property
- Public Property Password() As String
- Get
- Return _password
- End Get
- Set(ByVal value As String)
- _password = value
- End Set
- End Property
- Public Property Authenticated() As Boolean
- Get
- Return _authenticated
- End Get
- Set(ByVal value As Boolean)
- _authenticated = value
- End Set
- End Property
- ' Functions
- Public Function hasRole(ByVal intRoleID As Integer) As Boolean
- Return _roles.Contains(intRoleID)
- End Function
- Public Function Role() As Integer
- ' FOR BACKWARDS COMPATIBILITY ONLY - RETURN "BEST" ROLE
- Dim r As New ArrayList
- r = _roles
- r.Sort()
- Return r.Item(0)
- End Function
- ' Subs
- Public Sub logon()
- ' Create a session for this user
- Dim eh As New errHandler(System.Web.HttpContext.Current.Request, False)
- Dim dal As New rogTransMgrData(eh, False)
- ' set key values
- _sessionID = dal.createSession(Me)
- _authenticated = True
- dal = Nothing
- eh = Nothing
- End Sub
- Public Sub logoff()
- ' Destory session and unlock all resources.
- Dim eh As New errHandler(System.Web.HttpContext.Current.Request, False)
- Dim dal As New rogTransMgrData(eh, False)
- ' kills sesh and unlocks all resources
- dal.endSession(Me)
- ' Reset key values
- _sessionID = Nothing
- _authenticated = False
- dal = Nothing
- eh = Nothing
- End Sub
- Public Sub loadUserData()
- ' Agent data should be loaded already
- If (Me.UserID >= 0) Then
- Dim eh As New errHandler(System.Web.HttpContext.Current.Request, False)
- Dim dal As New rogTransMgrData(eh, False)
- Using ds As DataSet = dal.loadUser(UserID)
- If (ds.Tables.Count = 1) Then
- If (ds.Tables(0).Rows.Count = 1) Then
- With ds.Tables(0).Rows(0)
- _privLevel = .Item(ROG.Constants.DataSchema.Tables.Users.columns.PRIV)
- _username = .Item(ROG.Constants.DataSchema.Tables.Users.columns.USERNAME)
- _password = .Item(ROG.Constants.DataSchema.Tables.Users.columns.PASSWORD)
- _roles.Clear()
- _roles.Add(.Item(ROG.Constants.DataSchema.Tables.Users.columns.ROLE))
- End With
- End If
- End If
- End Using
- dal = Nothing
- eh = Nothing
- End If
- End Sub
- Public Sub scratch()
- End Sub
- Public Sub setDefaults()
- _roles.Add(DEF_ROLE)
- End Sub
- Public Sub New()
- setDefaults()
- End Sub
- Public Sub New(ByVal intUserID As Integer)
- setDefaults()
- Me.UserID = intUserID
- If Me.UserID >= 0 Then
- Me.load(Me.UserID)
- Me.loadUserData()
- End If
- End Sub
- End Class
Add Comment
Please, Sign In to add comment