Guest User

Untitled

a guest
May 12th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. Imports Microsoft.VisualBasic
  2. Imports System.Data
  3.  
  4. Public Class objUser : Inherits objAgent : Implements IContact
  5. Private Const DEF_REMOTEIP As String = ""
  6. Private Const DEF_PRIVLEVEL As Integer = 0
  7. Private Const DEF_ROLE As Integer = -1
  8. Private Const DEF_USERNAME As String = ""
  9. Private Const DEF_PASSWORD As String = ""
  10. Private Const DEF_AUTHENTICATED As Boolean = False
  11.  
  12. Private _sessionID As Guid = Nothing
  13. Private _remoteIP As String = DEF_REMOTEIP
  14. Private _privLevel As Integer = DEF_PRIVLEVEL
  15. Private _roles As New ArrayList
  16. Private _username As String = DEF_USERNAME
  17. Private _password As String = DEF_PASSWORD
  18. Private _authenticated As Boolean = DEF_AUTHENTICATED
  19.  
  20. ' Properties
  21. Public Property SessionID() As Guid
  22. Get
  23. Return _sessionID
  24. End Get
  25. Set(ByVal value As Guid)
  26. _sessionID = value
  27. End Set
  28. End Property
  29. Public Property RemoteIP() As String
  30. Get
  31. Return _remoteIP
  32. End Get
  33. Set(ByVal value As String)
  34. _remoteIP = value
  35. End Set
  36. End Property
  37. Public Property Priv() As Integer
  38. Get
  39. Return _privLevel
  40. End Get
  41. Set(ByVal value As Integer)
  42. _privLevel = value
  43. End Set
  44. End Property
  45. Public Property Roles() As ArrayList
  46. Get
  47. Return _roles
  48. End Get
  49. Set(ByVal value As ArrayList)
  50. _roles = value
  51. End Set
  52. End Property
  53. Public Property Username() As String
  54. Get
  55. Return _username
  56. End Get
  57. Set(ByVal value As String)
  58. _username = value
  59. End Set
  60. End Property
  61. Public Property Password() As String
  62. Get
  63. Return _password
  64. End Get
  65. Set(ByVal value As String)
  66. _password = value
  67. End Set
  68. End Property
  69. Public Property Authenticated() As Boolean
  70. Get
  71. Return _authenticated
  72. End Get
  73. Set(ByVal value As Boolean)
  74. _authenticated = value
  75. End Set
  76. End Property
  77.  
  78.  
  79. ' Functions
  80. Public Function hasRole(ByVal intRoleID As Integer) As Boolean
  81. Return _roles.Contains(intRoleID)
  82. End Function
  83. Public Function Role() As Integer
  84. ' FOR BACKWARDS COMPATIBILITY ONLY - RETURN "BEST" ROLE
  85. Dim r As New ArrayList
  86. r = _roles
  87. r.Sort()
  88. Return r.Item(0)
  89. End Function
  90.  
  91.  
  92. ' Subs
  93. Public Sub logon()
  94. ' Create a session for this user
  95. Dim eh As New errHandler(System.Web.HttpContext.Current.Request, False)
  96. Dim dal As New rogTransMgrData(eh, False)
  97.  
  98. ' set key values
  99. _sessionID = dal.createSession(Me)
  100. _authenticated = True
  101.  
  102. dal = Nothing
  103. eh = Nothing
  104. End Sub
  105. Public Sub logoff()
  106. ' Destory session and unlock all resources.
  107. Dim eh As New errHandler(System.Web.HttpContext.Current.Request, False)
  108. Dim dal As New rogTransMgrData(eh, False)
  109.  
  110. ' kills sesh and unlocks all resources
  111. dal.endSession(Me)
  112.  
  113. ' Reset key values
  114. _sessionID = Nothing
  115. _authenticated = False
  116.  
  117. dal = Nothing
  118. eh = Nothing
  119. End Sub
  120. Public Sub loadUserData()
  121. ' Agent data should be loaded already
  122. If (Me.UserID >= 0) Then
  123. Dim eh As New errHandler(System.Web.HttpContext.Current.Request, False)
  124. Dim dal As New rogTransMgrData(eh, False)
  125.  
  126. Using ds As DataSet = dal.loadUser(UserID)
  127. If (ds.Tables.Count = 1) Then
  128. If (ds.Tables(0).Rows.Count = 1) Then
  129. With ds.Tables(0).Rows(0)
  130. _privLevel = .Item(ROG.Constants.DataSchema.Tables.Users.columns.PRIV)
  131. _username = .Item(ROG.Constants.DataSchema.Tables.Users.columns.USERNAME)
  132. _password = .Item(ROG.Constants.DataSchema.Tables.Users.columns.PASSWORD)
  133.  
  134. _roles.Clear()
  135. _roles.Add(.Item(ROG.Constants.DataSchema.Tables.Users.columns.ROLE))
  136. End With
  137. End If
  138. End If
  139. End Using
  140.  
  141. dal = Nothing
  142. eh = Nothing
  143. End If
  144. End Sub
  145.  
  146. Public Sub scratch()
  147.  
  148.  
  149.  
  150.  
  151. End Sub
  152.  
  153.  
  154. Public Sub setDefaults()
  155. _roles.Add(DEF_ROLE)
  156. End Sub
  157. Public Sub New()
  158. setDefaults()
  159. End Sub
  160.  
  161. Public Sub New(ByVal intUserID As Integer)
  162. setDefaults()
  163. Me.UserID = intUserID
  164. If Me.UserID >= 0 Then
  165. Me.load(Me.UserID)
  166. Me.loadUserData()
  167. End If
  168. End Sub
  169.  
  170. End Class
Add Comment
Please, Sign In to add comment