Public Class PkiMethods #Region " Instance Fields " Dim _edipi As String = String.Empty Dim _firstName As String = String.Empty Dim _fullName As String = String.Empty Dim _lastName As String = String.Empty Dim _middleName As String = String.Empty Dim _subjectCN As String = String.Empty Dim _suffix As String = String.Empty #End Region #Region " Properties " Public ReadOnly Property edipi() As String Get Return _edipi End Get End Property Public ReadOnly Property firstName() As String Get Return _firstName End Get End Property Public ReadOnly Property fullName() As String Get Return _fullName End Get End Property Public ReadOnly Property lastName() As String Get Return _lastName End Get End Property Public ReadOnly Property middleName() As String Get Return _middleName End Get End Property Public ReadOnly Property subjectCN() As String Get Return _subjectCN End Get End Property Public ReadOnly Property suffix() As String Get Return _suffix End Get End Property #End Region #Region " Methods " Public Sub Initialize() Dim _cert As String = String.Empty Dim _certPartLength As String = String.Empty Dim _certArray() As String If Not HttpContext.Current.Request.ServerVariables("CERT_SUBJECT") Is Nothing Then If Not HttpContext.Current.Request.ServerVariables("CERT_SUBJECT").ToString() = "" Then _cert = HttpContext.Current.Request.ServerVariables("CERT_SUBJECT").ToString() _certPartLength = InStr(1, _cert, "CN=", vbTextCompare) + 2 _cert = Right(_cert, (Len(_cert) - _certPartLength)) _subjectCN = _cert _certArray = Split(_cert, ".") _lastName = StrConv(_certArray(0), VbStrConv.ProperCase) _firstName = StrConv(_certArray(1), VbStrConv.ProperCase) _middleName = StrConv(_certArray(2), VbStrConv.ProperCase) If _certArray.Length < 5 Then _suffix = String.Empty _edipi = _certArray(3) Else _suffix = StrConv(_certArray(3), VbStrConv.ProperCase) _edipi = _certArray(4) End If If _suffix = String.Empty Then _fullName = _firstName & " " & Left(_middleName, 1) & ". " & _lastName Else _fullName = _firstName & " " & Left(_middleName, 1) & ". " & _lastName & ", " & _suffix & "." End If Else _edipi = String.Empty _fullName = String.Empty End If End If End Sub Public Function IsLoggedOn() As Boolean IsLoggedOn = False If Not HttpContext.Current.Session("username") Is Nothing Then If Not HttpContext.Current.Session("username").ToString = String.Empty Then IsLoggedOn = True End If End If End Function Public Sub Logoff() HttpContext.Current.Session.Remove("username") End Sub Public Sub Logon() If Not _fullName Is String.Empty Then HttpContext.Current.Session("username") = _fullName Else If Not HttpContext.Current.Session("username") Is Nothing Then HttpContext.Current.Session.Remove("username") End If End If End Sub #End Region End Class